From fc42477b0887cd02913c9de6ece38ef1b467ba2d Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 12 Dec 2024 16:41:07 +0530 Subject: [PATCH] fix: tests --- .../recipe/oauth2provider/interfaces.py | 10 +++++----- .../recipe/oauth2provider/recipe_implementation.py | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/supertokens_python/recipe/oauth2provider/interfaces.py b/supertokens_python/recipe/oauth2provider/interfaces.py index 57d34579..bbbb1e59 100644 --- a/supertokens_python/recipe/oauth2provider/interfaces.py +++ b/supertokens_python/recipe/oauth2provider/interfaces.py @@ -177,12 +177,12 @@ def from_json(json: Dict[str, Any]): def to_json(self) -> Dict[str, Any]: return { "status": "OK", - "accessToken": self.access_token, - "expiresIn": self.expires_in, - "idToken": self.id_token, - "refreshToken": self.refresh_token, + "access_token": self.access_token, + "expires_in": self.expires_in, + "id_token": self.id_token, + "refresh_token": self.refresh_token, "scope": self.scope, - "tokenType": self.token_type, + "token_type": self.token_type, } diff --git a/supertokens_python/recipe/oauth2provider/recipe_implementation.py b/supertokens_python/recipe/oauth2provider/recipe_implementation.py index 63228d37..e12d811e 100644 --- a/supertokens_python/recipe/oauth2provider/recipe_implementation.py +++ b/supertokens_python/recipe/oauth2provider/recipe_implementation.py @@ -387,7 +387,6 @@ async def token_exchange( request_body = { "iss": await OpenIdRecipe.get_issuer(user_context), "inputBody": body, - "authorizationHeader": authorization_header, } if body.get("grant_type") == "password": @@ -846,7 +845,7 @@ async def introspect_token( # If it fails, the token is not active, and we return early if is_access_token: try: - await self.validate_oauth2_access_token( + payload = await self.validate_oauth2_access_token( token=token, requirements=( OAuth2TokenValidationRequirements(scopes=scopes) @@ -856,17 +855,19 @@ async def introspect_token( check_database=False, user_context=user_context, ) + return ActiveTokenResponse(payload=payload) except Exception: return InactiveTokenResponse() # For tokens that passed local validation or if it's a refresh token, # validate the token with the database by calling the core introspection endpoint + request_body = {"token": token} + if scopes: + request_body["scope"] = " ".join(scopes) + res = await self.querier.send_post_request( NormalisedURLPath("/recipe/oauth/introspect"), - { - "token": token, - "scope": " ".join(scopes) if scopes else None, - }, + request_body, user_context=user_context, )