Skip to content

Instantly share code, notes, and snippets.

@dfwarden
Created April 30, 2013 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfwarden/5489005 to your computer and use it in GitHub Desktop.
Save dfwarden/5489005 to your computer and use it in GitHub Desktop.
Example of administrative OAuth 2.0 access to Google Group Settings API.
import httplib2
import oauth2client.client
import pprint
from apiclient.discovery import build
serviceacct_email = "<your service account email address>"
f = file('groupssettings-privatekey.p12', 'rb')
client_key = f.read()
f.close()
credentials = oauth2client.client.SignedJwtAssertionCredentials(
serviceacct_email,
client_key,
scope='https://www.googleapis.com/auth/apps.groups.settings',
sub='<email addy for a gapps domain admin>')
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with our good Credentials.
http = httplib2.Http()
http = credentials.authorize(http)
# Build a service object for interacting with the API.
service = build(serviceName='groupssettings', version='v1', http=http)
settings = service.groups().get(groupUniqueId='<email addy of a group in your gapps domain>').execute()
# Settings should now be a dict of that group's settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment