You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the simple, clean library to make calls from Python to one of the many supported Google APIs. This example uses the Google+ API:
# List my public Google+ activities.result=service.activities().list(userId='me', collection='public').execute()
tasks=result.get('items', [])
fortaskintasks:
printtask['title']
Use the library with Google App Engine
App Engine-specific helpers make quick work of authenticated calls to APIs. No need to worry about exchanging code for tokens; get right down to writing the meat of your application.
# Restrict access to users who've granted access to Calendar info.decorator=appengine.OAuth2DecoratorFromClientSecrets(
'client_secrets.json',
scope='https://www.googleapis.com/auth/calendar')
classMainHandler(webapp.RequestHandler):
@decorator.oauth_requireddefget(self):
http=decorator.http()
request=service.events().list(calendarId='primary')
Handle auth with fewer lines of code
The easy-to-use authentication library can reduce the code you have to write for OAuth 2.0. Sometimes a few lines is all you need.
# Authorize server-to-server interactions from Google Compute Engine.importhttplib2fromoauth2client.contribimportgcecredentials=gce.AppAssertionCredentials(
scope='https://www.googleapis.com/auth/devstorage.read_write')
http=credentials.authorize(httplib2.Http())
Activity
docs: Adds docs folder. Fixes googleapis#669 Fixes googleapis#670 Fixes
grant commentedon Jun 26, 2019
The docs are now added to the docs/ folder.
Fixed with #706.