def load_oauth2_credentials(self, fname_secret, fname_creds): store = Storage(fname_creds) if os.path.isfile(fname_creds): store.acquire_lock() self.credentials = store.locked_get() store.release_lock() else: flow = flow_from_clientsecrets(fname_secret, scope='https://mail.google.com/', redirect_uri='urn:ietf:wg:oauth:2.0:oob') auth_uri = flow.step1_get_authorize_url() webbrowser.open(auth_uri) auth_code = raw_input('Enter the auth code: ') self.credentials = flow.step2_exchange(auth_code) store.acquire_lock() store.locked_put(self.credentials) store.release_lock() self.credentials.set_store(store)
def load_oauth2_credentials(self, fname_secret, fname_creds): store = Storage(fname_creds) if os.path.isfile(fname_creds): store.acquire_lock() self.credentials = store.locked_get() store.release_lock() else: flow = flow_from_clientsecrets( fname_secret, scope='https://mail.google.com/', redirect_uri='urn:ietf:wg:oauth:2.0:oob') auth_uri = flow.step1_get_authorize_url() webbrowser.open(auth_uri) auth_code = raw_input('Enter the auth code: ') self.credentials = flow.step2_exchange(auth_code) store.acquire_lock() store.locked_put(self.credentials) store.release_lock() self.credentials.set_store(store)
# This example uses Google APIs Client for Python, you can download it here: # https://developers.google.com/api-client-library/python/ import apiclient import httplib2 from oauth2client.file import Storage DISCOVERY_URL = ( 'https://monorail-staging.appspot.com/_ah/api/discovery/v1/apis/' '{api}/{apiVersion}/rest') # Get credentials to authorize http object storage = Storage('Your-local-credential-file') storage.acquire_lock() credentials = storage.get() http = credentials.authorize(httplib2.Http()) # Create monorail client using Google APIs Client for Python monorail = apiclient.discovery.build( 'monorail', 'v1', discoveryServiceUrl=DISCOVERY_URL, http=http) # Get all issues of chromium issues = monorail.issues().list(projectId='chromium').execute()
# This example uses Google APIs Client for Python, you can download it here: # https://developers.google.com/api-client-library/python/ import apiclient import httplib2 from oauth2client.file import Storage DISCOVERY_URL = ( 'https://monorail-staging.appspot.com/_ah/api/discovery/v1/apis/' '{api}/{apiVersion}/rest') # Get credentials to authorize http object storage = Storage('Your-local-credential-file') storage.acquire_lock() credentials = storage.get() http = credentials.authorize(httplib2.Http()) # Create monorail client using Google APIs Client for Python monorail = apiclient.discovery.build('monorail', 'v1', discoveryServiceUrl=DISCOVERY_URL, http=http) # Get all issues of chromium issues = monorail.issues().list(projectId='chromium').execute()