From c60569166d81dbd46971fc68e56adce3e8021505 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Mon, 30 Dec 2024 17:03:28 +0530 Subject: [PATCH] fix: cyclic import --- supertokens_python/recipe/oauth2provider/api/auth.py | 3 ++- .../recipe/oauth2provider/api/end_session.py | 3 ++- supertokens_python/recipe/oauth2provider/api/logout.py | 3 ++- supertokens_python/recipe/oauth2provider/api/user_info.py | 7 ++++--- supertokens_python/recipe/oauth2provider/api/utils.py | 7 +++++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/supertokens_python/recipe/oauth2provider/api/auth.py b/supertokens_python/recipe/oauth2provider/api/auth.py index 96baad46..8acda58a 100644 --- a/supertokens_python/recipe/oauth2provider/api/auth.py +++ b/supertokens_python/recipe/oauth2provider/api/auth.py @@ -27,6 +27,8 @@ APIInterface, ) +from .utils import get_session + async def auth_get( _tenant_id: str, @@ -38,7 +40,6 @@ async def auth_get( RedirectResponse, ErrorOAuth2Response, ) - from supertokens_python.recipe.session.asyncio import get_session from supertokens_python.recipe.session.exceptions import TryRefreshTokenError if api_implementation.disable_auth_get is True: diff --git a/supertokens_python/recipe/oauth2provider/api/end_session.py b/supertokens_python/recipe/oauth2provider/api/end_session.py index a1a876cb..482899c3 100644 --- a/supertokens_python/recipe/oauth2provider/api/end_session.py +++ b/supertokens_python/recipe/oauth2provider/api/end_session.py @@ -22,6 +22,8 @@ from supertokens_python.types import GeneralErrorResponse from supertokens_python.utils import send_200_response, send_non_200_response +from .utils import get_session + if TYPE_CHECKING: from ..interfaces import ( APIOptions, @@ -82,7 +84,6 @@ async def end_session_common( user_context: Dict[str, Any], ) -> Optional[BaseResponse]: from ..interfaces import RedirectResponse, ErrorOAuth2Response - from supertokens_python.recipe.session.asyncio import get_session from supertokens_python.recipe.session.exceptions import TryRefreshTokenError if api_implementation is None: diff --git a/supertokens_python/recipe/oauth2provider/api/logout.py b/supertokens_python/recipe/oauth2provider/api/logout.py index 7f996835..0a67e6e7 100644 --- a/supertokens_python/recipe/oauth2provider/api/logout.py +++ b/supertokens_python/recipe/oauth2provider/api/logout.py @@ -20,6 +20,8 @@ from supertokens_python.framework import BaseResponse from supertokens_python.utils import send_200_response, send_non_200_response +from .utils import get_session + if TYPE_CHECKING: from ..interfaces import ( APIOptions, @@ -37,7 +39,6 @@ async def logout_post( FrontendRedirectResponse, ErrorOAuth2Response, ) - from supertokens_python.recipe.session.asyncio import get_session if api_implementation.disable_logout_post is True: return None diff --git a/supertokens_python/recipe/oauth2provider/api/user_info.py b/supertokens_python/recipe/oauth2provider/api/user_info.py index 20efde67..4e858f73 100644 --- a/supertokens_python/recipe/oauth2provider/api/user_info.py +++ b/supertokens_python/recipe/oauth2provider/api/user_info.py @@ -16,6 +16,7 @@ from typing import TYPE_CHECKING, Any, Dict, Optional +from supertokens_python.recipe.accountlinking.recipe import AccountLinkingRecipe from supertokens_python.utils import ( send_200_response, send_non_200_response_with_message, @@ -34,8 +35,6 @@ async def user_info_get( api_options: APIOptions, user_context: Dict[str, Any], ): - from supertokens_python.asyncio import get_user - if api_implementation.disable_user_info_get is True: return None @@ -98,7 +97,9 @@ async def user_info_get( user_id = payload["sub"] - user = await get_user(user_id, user_context) + user = await AccountLinkingRecipe.get_instance().recipe_implementation.get_user( + user_id=user_id, user_context=user_context + ) if user is None: api_options.response.set_header( diff --git a/supertokens_python/recipe/oauth2provider/api/utils.py b/supertokens_python/recipe/oauth2provider/api/utils.py index ebc56898..13052b72 100644 --- a/supertokens_python/recipe/oauth2provider/api/utils.py +++ b/supertokens_python/recipe/oauth2provider/api/utils.py @@ -53,7 +53,6 @@ async def login_get( FrontendRedirectionURLTypeTryRefresh, FrontendRedirectionURLTypeLogin, ) - from supertokens_python.recipe.session.asyncio import get_session_information login_request = await recipe_implementation.get_login_request( challenge=login_challenge, @@ -64,7 +63,11 @@ async def login_get( return login_request session_info = ( - await get_session_information(session.get_handle()) if session else None + await SessionRecipe.get_instance().recipe_implementation.get_session_information( + session.get_handle(), user_context + ) + if session + else None ) if not session_info: session = None