Skip to content

Commit

Permalink
add logs to learn what's up
Browse files Browse the repository at this point in the history
  • Loading branch information
seplee committed Apr 14, 2024
1 parent d89efc2 commit 241606a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -153,31 +155,35 @@ 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,
authorization_response=request.url,
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
# from Google that gives you the user's profile information,
# 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
Expand Down

0 comments on commit 241606a

Please sign in to comment.