Django oauth2 google not working on server -


i'm using outh2 authenticate. need google calendar v3 api. on localhost works fine. when publish on heroku server application error (based on error code timeout - after 30s). have created separeted google project (for google id , secret).

here code

import gflags import httplib2  apiclient.discovery import build oauth2client.file import storage oauth2client.client import oauth2webserverflow oauth2client.tools import run  flags = gflags.flags   def add_event(summary, location, datetime_start, datetime_end):      # set flow object used if need authenticate.     # sample uses oauth 2.0, , set oauth2webserverflow     # information needs authenticate. note called     # web server flow, can handle flow native     # applications     # client_id , client_secret copied api access tab on     # google apis console     flow = oauth2webserverflow(         client_id='##########################',         client_secret='#######################',         scope='https://www.googleapis.com/auth/calendar',         user_agent='###########',         #access_type='offline'     )      # disable local server feature, uncomment following line:     #flags.auth_local_webserver = false      # if credentials don't exist or invalid, run through native client     # flow. storage object ensure if successful     # credentials written file.     storage = storage('calendar.dat')     credentials = storage.get()     if credentials none or credentials.invalid == true:         credentials = run(flow, storage)      # create httplib2.http object handle our http requests , authorize     # our credentials.     http = httplib2.http()     http = credentials.authorize(http)      # build service object interacting api. visit     # google apis console     # developerkey own application.     service = build(servicename='calendar', version='v3', http=http,                     developerkey='###########################')      event = {         'summary': summary,         'location': location,         'start': {             'datetime': datetime_start,  # '2011-06-03t10:00:00.000-07:00',             'timezone': 'europe/ljubljana'         },         'end': {             'datetime': datetime_end,   # '2011-06-03t10:25:00.000-07:00',             'timezone': 'europe/ljubljana'         },         }      recurring_event = service.events().insert(calendarid='primary', body=event).execute()      return recurring_event['id'] 

when call add_event(summary, location, datetime_start, datetime_end) view on localhost works fine (authentication flow succesfull , event added calendar). on server receive timeout.

update:

i should somehow..any ideas?

your browser has been opened visit:      https://accounts.google.com/o/oauth2/auth?scope=.....  if browser on different machine exit , re-run              --noauth_local_webserver 

looks app tries open browser on heroku server oauth2 flow. explains why fails on server, not on machine.

instead of using oauth2client.tools.run, i'd suggest implement oauth2 integration seperately add_event.


Comments