From 209f6acbfc55349a5b2e8c725f51c2328c06d527 Mon Sep 17 00:00:00 2001 From: deflax Date: Sun, 7 Apr 2024 20:14:33 +0300 Subject: [PATCH] debug oauth errors --- src/forest/auth/routes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/forest/auth/routes.py b/src/forest/auth/routes.py index 35405e1..261bd39 100644 --- a/src/forest/auth/routes.py +++ b/src/forest/auth/routes.py @@ -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())