Disabling APIs
- 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.
To disable the API entirely, all you need to do is override the api implementation as undefined
.
For example, if you want to disable the consume code API, all you do is:
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
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", // This example will work with any flow.
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
consumeCodePOST: undefined
}
}
}
})
]
});
To disable an API entirely, all you need to do is override the api implementation with nil
.
For example, if you want to disable the consume code api from this recipe, all you do is this:
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{
Override: &plessmodels.OverrideStruct{
APIs: func(originalImplementation plessmodels.APIInterface) plessmodels.APIInterface {
//First we copy the original impl
newImplementation := originalImplementation
// We disable the sign in and sign up APIs
newImplementation.ConsumeCodePOST = nil
return newImplementation
},
},
}),
},
})
}
To disable an API entirely, all you need to do is override the api disable bool value to True
.
For example, if you want to disable the consume code api from this recipe, all you do is this:
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import passwordless
from supertokens_python.recipe.passwordless.interfaces import APIInterface
def apis_override(original_impl: APIInterface):
original_impl.disable_consume_code_post = True
return original_impl
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
passwordless.init(
flow_type="...",
contact_config=...,
override=passwordless.InputOverrideConfig(
apis=apis_override
)
)
]
)
important
You then need to define your own routes that will handle this API call. You can see the Frontend driver interface API spec here