Skip to content

Instantly share code, notes, and snippets.

@richieforeman
Created March 26, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richieforeman/a169aa95e6f97d37cf7d to your computer and use it in GitHub Desktop.
Save richieforeman/a169aa95e6f97d37cf7d to your computer and use it in GitHub Desktop.
import os
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
http = httplib2.Http()
SCOPES = [
'https://www.googleapis.com/auth/calendar'
]
SERVICE_ACCOUNT_EMAIL = '801883730557-744ngc0s9eh5md75gehkb98acppjjr61@developer.gserviceaccount.com'
KEY_PATH = os.path.expanduser('~/privatekey.p12')
DOMAIN_USER = 'richie@richieforeman.net' # somebody on the domain
def main():
credentials = SignedJwtAssertionCredentials(
service_account_name=SERVICE_ACCOUNT_EMAIL,
private_key=file(KEY_PATH).read(),
scope=SCOPES,
sub=DOMAIN_USER)
credentials.authorize(http)
service = build('calendar', 'v3', http=http)
# fetch simple calendar list.
print service.calendarList().list().execute()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment