I have everything setup for refresh_tokens to work properly, but I have found that after a while they stop working, and then can be fixed by restarting my django application. When I restart my application running in gunicorn, the tokens start working again.
Any ideas on why this is? Does django-social-auth cache somehow? My current solution is to restart my django application with a cron ever 20 minutes, but I would like to find the root cause of the problem.
Here is a stack trace. Any input would be greatly appreciated. Thank you.
oauth2==1.5.211
django-social-auth==0.7.25
The access_token is expired or invalid and can't be refreshed.
Traceback (most recent call last):
File "/apps/gcal/signals.py", line 155, in event_pre_save
response = service.events().patch(calendarId=calendarId, eventId=instance.eventId, body=event).execute()
File "/home/venv/lib/python2.7/site-packages/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/venv/lib/python2.7/site-packages/apiclient/http.py", line 676, in execute
body=self.body, headers=self.headers)
File "/home/venv/lib/python2.7/site-packages/oauth2client/util.py", line 128, in positional_wrapper return wrapped(*args, **kwargs)
File "/home/venv/lib/python2.7/site-packages/oauth2client/client.py", line 494, in new_request
self._refresh(request_orig)
File "/home/venv/lib/python2.7/site-packages/oauth2client/client.py", line 811, in _refresh
'The access_token is expired or invalid and can\'t be refreshed.')
A
Update:
When I run socia.refresh_token() i get the following error:
[05/Sep/2013 11:37:22] ERROR [gcal.views:82] HTTP Error 400: Bad Request
Traceback (most recent call last):
File "/apps/gcal/views.py", line 80, in connect_helper
social.refresh_token()
File "/venv/lib/python2.7/site-packages/social_auth/db/base.py", line 54, in refresh_token
response = backend.refresh_token(token)
File "/venv/lib/python2.7/site-packages/social_auth/backends/__init__.py", line 873, in refresh_token
return cls.process_refresh_token_response(dsa_urlopen(request).read())
File "/venv/lib/python2.7/site-packages/social_auth/utils.py", line 237, in dsa_urlopen
return urlopen(*args, **kwargs)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 406, in open
response = meth(req, response)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 444, in error
return self._call_chain(*args)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 527, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 400: Bad Request
I have everything setup for refresh_tokens to work properly, but I have found that after a while they stop working, and then can be fixed by restarting my django application. When I restart my application running in
gunicorn
, the tokens start working again.Any ideas on why this is? Does django-social-auth cache somehow? My current solution is to restart my django application with a cron ever 20 minutes, but I would like to find the root cause of the problem.
Here is a stack trace. Any input would be greatly appreciated. Thank you.
Update:
When I run
socia.refresh_token()
i get the following error: