22import json
33import os
44import traceback
5- from typing import Any , Callable , Dict , List , Optional , Tuple , TypeVar
5+ from typing import Any , Callable , Dict , List , Literal , Optional , Tuple , TypeVar , Union
66
77import override_logging
88from accountlinking import add_accountlinking_routes # pylint: disable=import-error
5656from supertokens_python .recipe .session import InputErrorHandlers , SessionContainer
5757from supertokens_python .recipe .session .framework .flask import verify_session
5858from supertokens_python .recipe .session .recipe import SessionRecipe
59+ from supertokens_python .recipe .session .utils import TokenTransferMethod
5960from supertokens_python .recipe .thirdparty .provider import UserFields , UserInfoMap
6061from supertokens_python .recipe .thirdparty .recipe import ThirdPartyRecipe
6162from supertokens_python .recipe .totp .recipe import TOTPRecipe
@@ -305,6 +306,13 @@ async def custom_unauthorised_callback(
305306 )
306307 return response
307308
309+ def get_token_transfer_method (
310+ _ : BaseRequest ,
311+ __ : bool ,
312+ ___ : Dict [str , Any ],
313+ ) -> Union [TokenTransferMethod , Literal ["any" ]]:
314+ return recipe_config_json .get ("getTokenTransferMethod" , "any" )
315+
308316 recipe_config_json = json .loads (recipe_config .get ("config" , "{}" ))
309317 recipe_list .append (
310318 session .init (
@@ -325,6 +333,7 @@ async def custom_unauthorised_callback(
325333 use_dynamic_access_token_signing_key = recipe_config_json .get (
326334 "useDynamicAccessTokenSigningKey"
327335 ),
336+ get_token_transfer_method = get_token_transfer_method ,
328337 override = session .InputOverrideConfig (
329338 apis = override_builder_with_logging (
330339 "Session.override.apis" ,
0 commit comments