Call Google APIs simplyUse 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', ) for task in tasks: print task['title']
Handle auth with fewer lines of codeThe 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. from oauth2client.contrib import gce credentials = gce.AppAssertionCredentials( scope='https://www.googleapis.com/auth/devstorage.read_write') http = credentials.authorize(httplib2.Http())
Use the library with Google App EngineApp 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') class MainHandler(webapp.RequestHandler): @decorator.oauth_required def get(self): http = decorator.http() request = service.events().list(calendarId='primary')
Use standard tools for installationYou can install the library using standard Python tools, and there are custom installs optimized for Google App Engine.
$ pip install --upgrade google-api-python-client