How to use
- NodeJS
- GoLang
- Python
info
See all the functions that can be overrided here
import SuperTokens from "supertokens-node";
import ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";
SuperTokens.init({
    appInfo: {
        apiDomain: "...",
        appName: "...",
        websiteDomain: "..."
    },
    recipeList: [
        ThirdPartyPasswordless.init({
            contactMethod: "EMAIL", // This example will work with any contactMethod
            flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", // This example will work with any flow.
            override: {
                apis: (originalImplementation) => {
                    return {
                        ...originalImplementation,
                        // here we only override the API that is called when a user
                        // clicks on a magic link or enters an OTP
                        consumeCodePOST: async function (input) {
                            if (originalImplementation.consumeCodePOST === undefined) {
                                throw Error("Should never come here")
                            }
                            // TODO: some custom logic
                            // or call the default behaviour as show below
                            return await originalImplementation.consumeCodePOST(input);
                        },
                        // ...
                        // TODO: override more apis
                    };
                },
            },
        })
    ]
});
- originalImplementationis an object that contains apis that have the original implementation for this recipe. They can be used in your custom apis as a way to use the SuperTokens' default behaviour.
- In the above code snippet, we override the consumeCodePOSTapi of this recipe. This api will be called when the user clicks on a magic link or enters an OTP.
info
See all the functions that can be overrided here
import (
    "github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"
    "github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless"
    "github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless/tplmodels"
    "github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
    supertokens.Init(supertokens.TypeInput{
        RecipeList: []supertokens.Recipe{
            thirdpartypasswordless.Init(tplmodels.TypeInput{
                Override: &tplmodels.OverrideStruct{
                    APIs: func(originalImplementation tplmodels.APIInterface) tplmodels.APIInterface {
                        //First we copy the original impl function
                        originalConsumeCodePOST := *originalImplementation.ConsumeCodePOST
                        // Then we override the functions we want to
                        (*originalImplementation.ConsumeCodePOST) = func(userInput *plessmodels.UserInputCodeWithDeviceID, linkCode *string, preAuthSessionID string, options plessmodels.APIOptions, userContext supertokens.UserContext) (tplmodels.ConsumeCodePOSTResponse, error) {
                            // TODO: some custom logic
                            // or call the default behaviour as show below
                            return originalConsumeCodePOST(userInput, linkCode, preAuthSessionID, options, userContext)
                        }
                        // TODO: Override more APIs
                        return originalImplementation
                    },
                },
            }),
        },
    })
}
- originalImplementationis an object that contains apis that have the original implementation for this recipe. They can be used in your custom apis as a way to use the SuperTokens' default behaviour.
- In the above code snippet, we override the ConsumeCodePOSTapi of this recipe. This api will be called when the user clicks on a magic link or enters an OTP.
info
See all the functions that can be overrided here
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdpartypasswordless
from supertokens_python.recipe.thirdpartypasswordless.interfaces import (
    ConsumeCodePostOkResult, ConsumeCodePostRestartFlowError, ConsumeCodePostIncorrectUserInputCodeError, ConsumeCodePostExpiredUserInputCodeError,
    APIInterface, PasswordlessAPIOptions)
from typing import Union, Dict, Any
from supertokens_python.types import GeneralErrorResponse
def override_thirdpartypasswordless_apis(original_implementation: APIInterface):
    original_consume_code_post = original_implementation.consume_code_post
    async def consume_code_post(pre_auth_session_id: str,
                                user_input_code: Union[str, None],
                                device_id: Union[str, None],
                                link_code: Union[str, None],
                                api_options: PasswordlessAPIOptions,
                                user_context: Dict[str, Any]) -> Union[ConsumeCodePostOkResult, ConsumeCodePostRestartFlowError, ConsumeCodePostIncorrectUserInputCodeError, ConsumeCodePostExpiredUserInputCodeError,
                                                                       GeneralErrorResponse]:
        # TODO: some custom logic
        # or call the default behaviour as show below
        return await original_consume_code_post(pre_auth_session_id, user_input_code, device_id, link_code, api_options, user_context)
    original_implementation.consume_code_post = consume_code_post
    return original_implementation
init(
    app_info=InputAppInfo(
        api_domain="...", app_name="...", website_domain="..."),
    framework='...',  
    recipe_list=[
        thirdpartypasswordless.init(
            contact_config=...,  
            flow_type="...",  
            override=thirdpartypasswordless.InputOverrideConfig(
                apis=override_thirdpartypasswordless_apis
            )
        )
    ]
)
- original_implementationis an object that contains apis that have the original implementation for this recipe. They can be used in your custom apis as a way to use the SuperTokens' default behaviour.
- In the above code snippet, we override the consume_code_postapi of this recipe. This api will be called when the user clicks on a magic link or enters an OTP.