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
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
// 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/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{
GetCustomUserInputCode: func(userContext supertokens.UserContext) (string, error) {
// TODO:
return "123abcd", nil
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdpartypasswordless
from typing import Dict, Any
async def get_custom_user_input_code(user_context: Dict[str, Any]):
return "123abcd" # TODO
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
thirdpartypasswordless.init(
contact_config=...,
flow_type="...",
get_custom_user_input_code=get_custom_user_input_code
)
]
)