debug oauth errors
This commit is contained in:
parent
4bf546e402
commit
209f6acbfc
1 changed files with 5 additions and 0 deletions
|
@ -59,10 +59,12 @@ def oauth2_callback(provider):
|
|||
# make sure that the state parameter matches the one we created in the
|
||||
# authorization request
|
||||
if request.args['state'] != session.get('oauth2_state'):
|
||||
print('oauth2 missing arg state!', file=sys.stderr)
|
||||
abort(401)
|
||||
|
||||
# make sure that the authorization code is present
|
||||
if 'code' not in request.args:
|
||||
print('oauth missing code', file=sys.stderr)
|
||||
abort(401)
|
||||
|
||||
# exchange the authorization code for an access token
|
||||
|
@ -75,9 +77,11 @@ def oauth2_callback(provider):
|
|||
_external=True),
|
||||
}, headers={'Accept': 'application/json'})
|
||||
if response.status_code != 200:
|
||||
print('oauth response code is not 200', file=sys.stderr)
|
||||
abort(401)
|
||||
oauth2_token = response.json().get('access_token')
|
||||
if not oauth2_token:
|
||||
print('oauth no access token', file=sys.stderr)
|
||||
abort(401)
|
||||
|
||||
# use the access token to get the user's email address
|
||||
|
@ -86,6 +90,7 @@ def oauth2_callback(provider):
|
|||
'Accept': 'application/json',
|
||||
})
|
||||
if response.status_code != 200:
|
||||
print('oauth no user info', file=sys.stderr)
|
||||
abort(401)
|
||||
email = provider_data['userinfo']['email'](response.json())
|
||||
|
||||
|
|
Loading…
Reference in a new issue