Skip to content

Commit

Permalink
fix login KeyError id_token after authlib-1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
QSummerY committed Jul 8, 2024
1 parent 9bd23d2 commit 3386605
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions helpdesk/views/auth/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ async def callback(oauth_provider: str, request: Request):
oauth_client = oauth_clients[oauth_provider]

token = await oauth_client.authorize_access_token(request)
id_token = await oauth_client.parse_id_token(request, token)
logger.debug("auth succeed %s", id_token)
userinfo = token['userinfo']
logger.debug("auth succeed %s", userinfo)

username = oauth_username_func(id_token)
email = id_token['email']
username = oauth_username_func(userinfo)
email = userinfo['email']

access = id_token.get('resource_access', {})
access = userinfo.get('resource_access', {})
roles = access.get(oauth_client.client_id, {}).get('roles', [])

user = User(name=username, email=email, roles=roles, avatar=id_token.get('picture'))
user = User(name=username, email=email, roles=roles, avatar=userinfo.get('picture', ''))

request.session['user'] = user.json()

Expand Down

0 comments on commit 3386605

Please sign in to comment.