@@ -60,6 +60,7 @@ def get_provider_config_for_client(
6060 require_email = config .require_email ,
6161 validate_id_token_payload = config .validate_id_token_payload ,
6262 generate_fake_email = config .generate_fake_email ,
63+ validate_access_token = config .validate_access_token ,
6364 )
6465
6566
@@ -375,7 +376,8 @@ async def exchange_auth_code_for_oauth_tokens(
375376 access_token_params ["redirect_uri" ] = DEV_OAUTH_REDIRECT_URL
376377 # Transformation needed for dev keys END
377378
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
379381
380382 async def get_user_info (
381383 self , oauth_tokens : Dict [str , Any ], user_context : Dict [str , Any ]
@@ -402,25 +404,29 @@ async def get_user_info(
402404 user_context ,
403405 )
404406
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 :
406413 headers : Dict [str , str ] = {"Authorization" : f"Bearer { access_token } " }
407414 query_params : Dict [str , str ] = {}
408415
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+ )
419420
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
422424 )
423425
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+
424430 user_info_result = get_supertokens_user_info_result_from_raw_user_info (
425431 self .config , raw_user_info_from_provider
426432 )
0 commit comments