Skip to content

Commit

Permalink
Merge pull request authlib#74 from watdev2018/patch-1
Browse files Browse the repository at this point in the history
Allow for async code to run in handle_authorize
  • Loading branch information
lepture authored Dec 8, 2020
2 parents 1b60be9 + 9380758 commit 635823a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions loginpass/_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_fastapi_routes(backends, oauth, handle_authorize):
app.add_middleware(SessionMiddleware, secret_key=config.get("SECRET_KEY"))
def handle_authorize(remote, token, user_info, request):
async def handle_authorize(remote, token, user_info, request):
return user_info
router = create_fastapi_routes([GitHub, Google], oauth, handle_authorize)
Expand Down Expand Up @@ -63,13 +63,13 @@ async def auth(
token = await remote.authorize_access_token(request)
else:
# handle failed
return handle_authorize(remote, None, None)
return await handle_authorize(remote, None, None)
if "id_token" in token:
user_info = await remote.parse_id_token(request, token)
else:
remote.token = token
user_info = await remote.userinfo(token=token)
return handle_authorize(remote, token, user_info, request)
return await handle_authorize(remote, token, user_info, request)

@router.get("/login/{backend}")
async def login(backend: str, request: Request):
Expand Down

0 comments on commit 635823a

Please sign in to comment.