command_line 

Send to Kindle
home » snippets » appengine » command_line



Snippets

OAuth token management

Here's one approach toward managing it.

import keyring

# Store OAuth token for later use.
def save_oauth2_refresh_token(email, oauth2_refresh_token):
    keyring.set_password(
        "OAuth2 Refresh Token: " + email + ": AppengineLauncher",
        email,
        oauth2_refresh_token)


# Sample call.
import getpass
save_oauth2_refresh_token("email@....", getpass.getpass())


def get_oauth2_refresh_token(email):
    return keyring.get_password(
        "OAuth2 Refresh Token: " + email + ": AppengineLauncher",
        email)

And wrap the call to appcfg.py using get_oauth2_refresh_token to pass in the --oauth2_refresh_token param (remember to also pass in --oauth2, --no_cookies and --noauth_local_webserver)