Changing OTP format
By default, the generated OTP is 6 digits long and is numbers only. You can change this to be any length you like and have any charset by providing the getCustomUserInputCode function.
- 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.
import SuperTokens from "supertokens-node";
import Passwordless from "supertokens-node/recipe/passwordless";
SuperTokens.init({
    appInfo: {
        apiDomain: "...",
        appName: "...",
        websiteDomain: "..."
    },
    recipeList: [
        Passwordless.init({
            contactMethod: "EMAIL", // This example will work with any contactMethod
            // This example works with the "USER_INPUT_CODE_AND_MAGIC_LINK" and "USER_INPUT_CODE" flows.
            flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", 
            getCustomUserInputCode: async (userCtx) => {
                // TODO:
                return "123abcd";
            },
        })
    ]
});
import (
    "github.com/supertokens/supertokens-golang/recipe/passwordless"
    "github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"
    "github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
    supertokens.Init(supertokens.TypeInput{
        RecipeList: []supertokens.Recipe{
            passwordless.Init(plessmodels.TypeInput{
                GetCustomUserInputCode: func(tenantId string, userContext supertokens.UserContext) (string, error) {
                    // TODO:
                    return "123abcd", nil
                },
            }),
        },
    })
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import passwordless
from typing import Dict, Any
async def get_custom_user_input_code(tenant_id: str, user_context: Dict[str, Any]):
    return "123abcd" # TODO
init(
    app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
    framework='...', 
    recipe_list=[
        passwordless.init(
            contact_config=..., 
            flow_type="...", 
            get_custom_user_input_code=get_custom_user_input_code
        )
    ]
)