Skip to content

DevSite Import: Python Client Home #669

@grant

Description

@grant

Notice: This DevSite page will soon be deleted per b/133171590. Please add this sample to GitHub if it is relevant still:

https://developers.google.com/api-client-library/python/


Easily access Google APIs from Python

Call Google APIs simply

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', [])
 for task in tasks:
   print task['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')

 class MainHandler(webapp.RequestHandler):
   @decorator.oauth_required
   def get(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.
 import httplib2
 from oauth2client.contrib import gce

 credentials = gce.AppAssertionCredentials(
   scope='https://www.googleapis.com/auth/devstorage.read_write')
 http = credentials.authorize(httplib2.Http())

Use standard tools for installation

You 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

Metadata

Metadata

Assignees

Labels

type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions