Skip to content

Commit

Permalink
update:google auth module
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Jun 28, 2024
1 parent b9c47bb commit 8075f75
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/backend/app/users/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ def callback(self, callback_url: str) -> str:
resp = self.oauth.get(user_api_url)
if resp.status_code != 200:
raise ValueError("Invalid response from Google")
data = resp.json().get("user")

data = resp.json()
serializer = URLSafeSerializer(self.secret_key)
user_data = {
"id": data.get("id"),
"username": data.get("display_name"),
"img_url": data.get("img").get("href") if data.get("img") else None,
"email": data.get("email"),
"name": data.get("name"),
"img_url": data.get("picture") if data.get("picture") else None,
}
token = serializer.dumps(user_data)
access_token = base64.b64encode(bytes(token, "utf-8")).decode("utf-8")
Expand Down

0 comments on commit 8075f75

Please sign in to comment.