Skip to content

Instantly share code, notes, and snippets.

@wxg4net
Last active December 28, 2015 16:09
Show Gist options
  • Save wxg4net/7527372 to your computer and use it in GitHub Desktop.
Save wxg4net/7527372 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
# -*- coding: utf-8 -*-
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
import httplib2
from oauth2client.tools import run
from apiclient.discovery import build
#~ flow = flow_from_clientsecrets('client_secrets.json',
#~ scope='https://www.googleapis.com/auth/tasks',
#~ redirect_uri='urn:ietf:wg:oauth:2.0:oob')
#~
#~ auth_uri = flow.step1_get_authorize_url()
#~ print auth_uri
#~ code = raw_input("Input Code :")
#~ credentials = flow.step2_exchange(code)
storage = Storage('credentials.log')
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = run(flow, storage)
httplib2.debuglevel=4
http = httplib2.Http(ca_certs='/usr/share/goagent/local/cacert.pem', disable_ssl_certificate_validation=True)
http = credentials.authorize(http)
service = build('tasks', 'v1', http=http)
result = service.tasks().list(tasklist='@default').execute()
tasks = result.get('items', [])
for task in tasks:
for k in task:
print "dict[%s] =" % k,task[k]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment