Merge pull request #6339 from Cyb4Black/fix-not-rely-on-id-token-for-user-info

fix: get userinfo from endpoint, not only from token
This commit is contained in:
Timothy Jaeryang Baek 2024-10-22 13:36:30 -07:00 committed by GitHub
commit 170ec2f9d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -139,6 +139,11 @@ class OAuthManager:
log.warning(f"OAuth callback error: {e}")
raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_CRED)
user_data: UserInfo = token["userinfo"]
if not user_data:
user_data: UserInfo = await client.userinfo(token=token)
if not user_data:
log.warning(f"OAuth callback failed, user data is missing: {token}")
raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_CRED)
sub = user_data.get("sub")
if not sub: