From 241606ac2d99ca277287202faa37f6ed66f51fbd Mon Sep 17 00:00:00 2001 From: Lee Harrold Date: Sun, 14 Apr 2024 10:40:52 -0400 Subject: [PATCH] add logs to learn what's up --- api/backend/app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/backend/app.py b/api/backend/app.py index 310403f..57707af 100644 --- a/api/backend/app.py +++ b/api/backend/app.py @@ -144,7 +144,9 @@ def login(): @app.route("/api/login/callback") def callback(): - + print("I think both of the below urls need to use https") + print(f"request url: {request.url}") + print(f"request base url: {request.base_url}") print("got to the callback, friendo") # Get authorization code Google sent back to you code = request.args.get("code") @@ -153,7 +155,7 @@ def callback(): # things on behalf of a user google_provider_cfg = get_google_provider_cfg() token_endpoint = google_provider_cfg["token_endpoint"] - + print(f"token endpoint {token_endpoint}") # Prepare and send a request to get tokens! Yay tokens! token_url, headers, body = client.prepare_token_request( token_endpoint, @@ -161,15 +163,17 @@ def callback(): redirect_url=request.base_url, code=code ) + print(f"token url {token_url}") token_response = requests.post( token_url, headers=headers, data=body, auth=(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET), ) - + print(f"we probably get to here before the error") # Parse the tokens! client.parse_request_body_response(json.dumps(token_response.json())) + print(f"I don't expect to see this message.") # Now that you have tokens (yay) let's find and hit the URL @@ -177,7 +181,9 @@ def callback(): # including their Google profile image and email userinfo_endpoint = google_provider_cfg["userinfo_endpoint"] uri, headers, body = client.add_token(userinfo_endpoint) + print(f"improbably, we have added a token") userinfo_response = requests.get(uri, headers=headers, data=body) + print(f"perhaps it fails after userinfo_response") # You want to make sure their email is verified. # The user authenticated with Google, authorized your