Created
May 12, 2014 10:56
-
-
Save ojarva/41ea01cf5c4302234a91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from oauth2client.client import flow_from_clientsecrets | |
from oauth2client.client import OAuth2WebServerFlow | |
from oauth2client.file import Storage | |
storage = Storage('a_credentials_file') | |
credentials = storage.get() | |
if not credentials: | |
flow = flow_from_clientsecrets('client_secrets.json', | |
scope='https://www.googleapis.com/auth/admin.reports.audit.readonly', | |
redirect_uri='urn:ietf:wg:oauth:2.0:oob') | |
auth_uri = flow.step1_get_authorize_url() | |
print auth_uri | |
code = raw_input("Auth token: ") | |
credentials = flow.step2_exchange(code) | |
storage.put(credentials) | |
http = httplib2.Http() | |
http = credentials.authorize(http) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment