puiterwijk / flask-oidc

OpenID Connect support for Flask
BSD 2-Clause "Simplified" License
156 stars 218 forks source link

Traceback on errors during the refresh process #46

Open abompard opened 6 years ago

abompard commented 6 years ago

On Hubs I get this traceback sometimes:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1637, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1837, in preprocess_request
    rv = func()
  File "/usr/lib/python3.6/site-packages/flask_oidc/__init__.py", line 324, in _before_request
    self.authenticate_or_redirect()
  File "/usr/lib/python3.6/site-packages/flask_oidc/__init__.py", line 362, in authenticate_or_redirect
    credentials.refresh(httplib2.Http())
  File "/usr/lib/python3.6/site-packages/oauth2client/client.py", line 545, in refresh
    self._refresh(http)
  File "/usr/lib/python3.6/site-packages/oauth2client/client.py", line 749, in _refresh
    self._do_refresh_request(http)
  File "/usr/lib/python3.6/site-packages/oauth2client/client.py", line 786, in _do_refresh_request
    self.access_token = d['access_token']
KeyError: 'access_token'

I've printed the value of the variable d and it's {'error_description': 'Something went wrong refreshing', 'error': 'invalid_grant'}.

abompard commented 6 years ago

Apparently the server sometimes returns an error but with a HTTP 200 code, which sends the execution into the wrong code path.

bkabrda commented 6 years ago

I'm experiencing this issue as well. @abompard did you manage to find a fix or a workaround?