from oauth2client.client import OAuth2WebServerFlow from oauth2client.file import Storage flow = OAuth2WebServerFlow(client_id='34462582242-4kpdvvbi27ajt4u22uitqurpve9o8ipj.apps.googleusercontent.com', client_secret='y4t9XBrJdCODPTO5UvtONWWn', scope='https://www.googleapis.com/auth/calendar', redirect_uri='http://localhost') createLink = False if createLink: auth_uri = flow.step1_get_authorize_url() print "AuthURI:" print auth_uri print "Visit this link - grab the key from the url and paste it into the else block" exit(0) else: #code = "4/Iais8aK8_KxbMQjq3Rtw3PFXu6Nr.8itpukY_6ZgZOl05ti8ZT3ax27a3hAI" #code = "4/YjdxGI8sIokRhYVE18ut9WMeYbmRLfazB-HOGCyqo4M#" code = "4/3EhMJx4WlXrZhyEwGGiHG-rhJzZAPrALFEYJpfvp5J8#" credentials = flow.step2_exchange( code ) storage = Storage('calendarCredentials.dat') storage.put( credentials )