How to use
Use the override config#
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK  to authenticate requests and issue session tokens.
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
                    }
                }
            }
        })
    ]
});
- originalImplementationis 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 signInUpfunction 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 string, thirdPartyUserID string, email string, oAuthTokens map[string]interface{}, rawUserInfoFromProvider tpmodels.TypeRawUserInfoFromProvider, tenantId string, userContext *map[string]interface{}) (tpmodels.SignInUpResponse, error) {
                            // TODO: some custom logic
                            // or call the default behaviour as show below
                            return originalSignInUp(thirdPartyID, thirdPartyUserID, email, oAuthTokens, rawUserInfoFromProvider, tenantId, userContext)
                        }
                        // TODO: Override more functions
                        return originalImplementation
                    },
                },
            }),
        },
    })
}
- originalImplementationis 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 signInUpfunction 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, InputAppInfo
from supertokens_python.recipe import thirdparty
from supertokens_python.recipe.thirdparty.interfaces import RecipeInterface
from supertokens_python.recipe.thirdparty.types import RawUserInfoFromProvider
from 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,
        oauth_tokens: Dict[str, Any],
        raw_user_info_from_provider: RawUserInfoFromProvider,
        tenant_id: 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, oauth_tokens, raw_user_info_from_provider, tenant_id, 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_implementationis 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_upfunction of this recipe. This function will be used to handle the scenario when the user clicks on the sign up button from the frontend.