Created
March 26, 2015 22:10
-
-
Save richieforeman/a169aa95e6f97d37cf7d to your computer and use it in GitHub Desktop.
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 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 = '[email protected]' # 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