How to use
#
Use the override config- NodeJS
- GoLang
- Python
info
See all the functions that can be overrided here
import SuperTokens from "supertokens-node";import ThirdParty from "supertokens-node/recipe/thirdparty";
SuperTokens.init({ appInfo: { apiDomain: "...", appName: "...", websiteDomain: "..." }, supertokens: { connectionURI: "...", }, recipeList: [ ThirdParty.init({ signInAndUpFeature: { providers: [/* ... */] }, override: { functions: (originalImplementation) => { return { ...originalImplementation,
// here we are only overriding the function that's responsible // for signing in or signing up a user. signInUp: async function (input) { // TODO: some custom logic
// or call the default behaviour as show below return await originalImplementation.signInUp(input); }, // ... // TODO: override more functions } } } }) ]});
originalImplementation
is an object that contains functions that have the original implementation for this recipe. They can be used in your functions as a way to use the SuperTokens' default behaviour.- In the above code snippet, we override the
signInUp
function of this recipe. This function will be used to handle the scenario where a user either signs up or signs in via any third party provider.
info
See all the functions that can be overrided here
import ( "github.com/supertokens/supertokens-golang/recipe/thirdparty" "github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels" "github.com/supertokens/supertokens-golang/supertokens")
func main() { supertokens.Init(supertokens.TypeInput{ RecipeList: []supertokens.Recipe{ thirdparty.Init(&tpmodels.TypeInput{ Override: &tpmodels.OverrideStruct{ Functions: func(originalImplementation tpmodels.RecipeInterface) tpmodels.RecipeInterface {
//First we copy the original impl originalSignInUp := *originalImplementation.SignInUp
// Then we override the functions we want to (*originalImplementation.SignInUp) = func(thirdPartyID, thirdPartyUserID string, email string, userContext supertokens.UserContext) (tpmodels.SignInUpResponse, error) { // TODO: some custom logic
// or call the default behaviour as show below return originalSignInUp(thirdPartyID, thirdPartyUserID, email, userContext) }
// TODO: Override more functions
return originalImplementation }, }, }), }, })}
originalImplementation
is an object that contains functions that have the original implementation for this recipe. They can be used in your functions as a way to use the SuperTokens' default behaviour.- In the above code snippet, we override the
signInUp
function of this recipe. This function will be used to handle the scenario where a user either signs up or signs in via any third party provider.
info
See all the functions that can be overrided here
from supertokens_python import init, InputAppInfofrom supertokens_python.recipe import thirdpartyfrom supertokens_python.recipe.thirdparty.interfaces import RecipeInterfacefrom typing import Dict, Any
def override_thirdparty_functions(original_implementation: RecipeInterface): original_sign_in_up = original_implementation.sign_in_up
async def sign_in_up(third_party_id: str, third_party_user_id: str, email: str, user_context: Dict[str, Any]): # TODO: custom logic
# or call the default behaviour as show below return await original_sign_in_up(third_party_id, third_party_user_id, email, user_context) original_implementation.sign_in_up = sign_in_up return original_implementation
init( app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."), framework='...', recipe_list=[ thirdparty.init( override=thirdparty.InputOverrideConfig( functions=override_thirdparty_functions ), sign_in_and_up_feature=thirdparty.SignInAndUpFeature(providers=[ #... ]) ) ])
original_implementation
is an object that contains functions that have the original implementation for this recipe. They can be used in your functions as a way to use the SuperTokens' default behaviour.- In the above code snippet, we override the
sign_in_up
function of this recipe. This function will be used to handle the scenario when the user clicks on the sign up button from the frontend.