@@ -60,6 +60,7 @@ def get_provider_config_for_client(
60
60
require_email = config .require_email ,
61
61
validate_id_token_payload = config .validate_id_token_payload ,
62
62
generate_fake_email = config .generate_fake_email ,
63
+ validate_access_token = config .validate_access_token ,
63
64
)
64
65
65
66
@@ -375,7 +376,8 @@ async def exchange_auth_code_for_oauth_tokens(
375
376
access_token_params ["redirect_uri" ] = DEV_OAUTH_REDIRECT_URL
376
377
# Transformation needed for dev keys END
377
378
378
- return await do_post_request (token_api_url , access_token_params )
379
+ _ , body = await do_post_request (token_api_url , access_token_params )
380
+ return body
379
381
380
382
async def get_user_info (
381
383
self , oauth_tokens : Dict [str , Any ], user_context : Dict [str , Any ]
@@ -402,25 +404,29 @@ async def get_user_info(
402
404
user_context ,
403
405
)
404
406
405
- if access_token is not None and self .config .token_endpoint is not None :
407
+ if self .config .validate_access_token is not None and access_token is not None :
408
+ await self .config .validate_access_token (
409
+ access_token , self .config , user_context
410
+ )
411
+
412
+ if access_token is not None and self .config .user_info_endpoint is not None :
406
413
headers : Dict [str , str ] = {"Authorization" : f"Bearer { access_token } " }
407
414
query_params : Dict [str , str ] = {}
408
415
409
- if self .config .user_info_endpoint is not None :
410
- if self .config .user_info_endpoint_headers is not None :
411
- headers = merge_into_dict (
412
- self .config .user_info_endpoint_headers , headers
413
- )
414
-
415
- if self .config .user_info_endpoint_query_params is not None :
416
- query_params = merge_into_dict (
417
- self .config .user_info_endpoint_query_params , query_params
418
- )
416
+ if self .config .user_info_endpoint_headers is not None :
417
+ headers = merge_into_dict (
418
+ self .config .user_info_endpoint_headers , headers
419
+ )
419
420
420
- raw_user_info_from_provider .from_user_info_api = await do_get_request (
421
- self .config .user_info_endpoint , query_params , headers
421
+ if self .config .user_info_endpoint_query_params is not None :
422
+ query_params = merge_into_dict (
423
+ self .config .user_info_endpoint_query_params , query_params
422
424
)
423
425
426
+ raw_user_info_from_provider .from_user_info_api = await do_get_request (
427
+ self .config .user_info_endpoint , query_params , headers
428
+ )
429
+
424
430
user_info_result = get_supertokens_user_info_result_from_raw_user_info (
425
431
self .config , raw_user_info_from_provider
426
432
)
0 commit comments