Skip to content
Stijn Debrouwere edited this page May 23, 2015 · 4 revisions

Convenience functions for authenticating with Google and asking for authorization with Google, with authenticate at its core.

authenticate will do what it says on the tin, but unlike the basic googleanalytics.oauth.authenticate, it also tries to get existing credentials from the keyring, from environment variables, it prompts for information when required and so on.

function authenticate(client_id=False, client_secret=False, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=None, save=None)

The authenticate function will authenticate the user with the Google Analytics API, using a variety of strategies: keyword arguments provided to this function, credentials stored in in environment variables, credentials stored in the keychain and, finally, by asking for missing information interactively in a command-line prompt.

If necessary (but only if interactive=True) this function will also allow the user to authorize this Python module to access Google Analytics data on their behalf, using an OAuth2 token.


function revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None)

Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics data and remove any stored credentials that use these tokens.