Here's a useful thing for people who write command-line OSM processing scripts in Python:
https://github.com/Zverik/cli-oauth2
Authenticate with OAuth2 in one line of code. Stores tokens permanently, doesn't require you to do anything else.
Just updated my Simple Revert and OSM to Sandbox scripts to use it.