Flexible connection switching is an optional feature that allows users to choose their method of authentication when logging in to an application. When implemented, your application’s login screen presents users with the option to authenticate with either traditional database credentials or a connection. Users who select a passwordless connection receive a one-time password (OTP) through email or SMS that they can use to log in to your application. Flexible connection switching uses custom Universal Login prompts to provide users with a more autonomous authentication experience.

Before you begin

Before you can implement flexible connection switching, ensure the following requirements are met:

Implement flexible connection switching

To implement this feature, use the Auth0 Management API to configure custom signup and login prompt partials. Partials refer to custom code inserted into an entry point within a prompt screen, such as the login screen. To learn more, review Customize Signup and Login Prompts. To implement flexible connection switching, you will configure custom prompt partials with the following parameters:
ParameterDescriptionExample
stateRenders the current page’s state value, which is opaque and used for security purposes.

To learn more about current screen information, review Customize Univeral Login Page Templates.
<input type=‘hidden’ name=‘state’ value=''>
connectionName and type of the connection.

For passwordless connections, value is either email or sms.
<input type=‘hidden’ name=‘connection’ value=‘email’>
In the code samples below, ensure you replace the placeholders with the appropriate values:
  • Replace {yourDomain} with yourdomain.auth0.com.
  • Replace {mgmtApiToken} with your access token.

Configure signup prompt

You can configure the signup-password prompt using the Set partials for a prompt endpoint:
curl --request PUT \
  --url 'https://{yourDomain}/api/v2/prompts/signup-password/partials' \
  --header 'authorization: Bearer {mgmtApiToken}' \
  --header 'content-type: application/json' \
  --data '{"signup-password":{"form-footer-start":"   Send a secure code by email "}}'
As a result, a Send a secure code by email button is added to the signup-password screen. When a user selects this button, it submits a form body containing the login state parameter and the name of the desired connection.

Configure login prompts

For best results, configuring the login prompt for both password and passwordless connections is recommended. You can configure the login-password prompt using the Set partials for a prompt endpoint:
curl --request PUT \
  --url 'https://{yourDomain}/api/v2/prompts/login-password/partials' \
  --header 'authorization: Bearer {mgmtApiToken}' \
  --header 'content-type: application/json' \
  --data '{"login-password":{"form-footer-start":"   Send a secure code by email "}}'
As a result, a Send a secure code by email button is added to the login-password screen. When a user selects this button, it submits a form body containing the login state parameter and the name of the desired connection. Similarly, you can configure the login-passwordless prompt using the Set partials for a prompt endpoint:
curl --request PUT \
  --url 'https://{yourDomain}/api/v2/prompts/login-passwordless/partials' \
  --header 'authorization: Bearer {mgmtApiToken}' \
  --header 'content-type: application/json' \
  --data '{"login-passwordless-email-code":{"form-footer-start":"   Use Password Instead "}}'