Created
April 30, 2013 14:14
-
-
Save dfwarden/5489005 to your computer and use it in GitHub Desktop.
Example of administrative OAuth 2.0 access to Google Group Settings API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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