Making it simple to call Google APIs
Use the simple and clean library to make calls from Python to an 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']
The easy-to-use authentication library can reduce the amount of code you need to write to handle OAuth 2.0. Sometimes as little as a couple of lines is all you need.
# Authorize server-to-server interactions from Google Compute Engine. from oauth2client import gce credentials = gce.AppAssertionCredentials( scope='https://www.googleapis.com/auth/devstorage.read_write') http = credentials.authorize(httplib2.Http())
Runs on 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 that have granted access to Calendar information. 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') ...
Client library installation
Install the library using standard Python tools.
$ pip install --upgrade google-api-python-client
There are also custom installs optimized for Google App Engine.
Check out all the installation options.