Passwordless Authentication with SMS

With an SMS connection, the user is asked to enter a phone number. By default, Auth0 uses Twilio to send a one-time-use code to that phone number. (If you have a custom SMS gateway, you can modify your connection to use that instead of Twilio.)

The user then enters the code into your application. If you are using Universal Login, make sure you configure Universal Login with Passwordless.

If the phone number attached to the code matches an existing user, Auth0 authenticates the user:

Existing User Flow

If the user is new, their user profile is created for the sms connection before they are authenticated by Auth0.

New User Flow

Navigate to Auth0 Dashboard > Authentication > Passwordless, and enable the SMS switch.

Enable SMS Passwordless

To send the SMS, you can either use Twilio, or a Custom SMS Gateway.

Configure Twilio settings

You will need a Twilio Account SID and a Twilio Auth Token. These are the Twilio API credentials that Auth0 will use to send an SMS to the user.

  1. Enter your Twilio Account SID and Twilio Auth Token.

To learn how to find your Twilio SID and Auth Token, see Twilio docs: How to create an Application SID and Auth Tokens and how to change them.

Configure SMS Passwordless

  1. Select your SMS Source and depending on your selection, enter either your Twilio Messaging Service SID or a From phone number. Users will see what you enter as the sender of the SMS.

To learn about using Twilio Messaging Services, see Twilio docs: Sending Messages with Messaging Services.

Configure a custom SMS gateway

If you would like to use your own SMS gateway, you will need to create the passwordless connection and then modify it using our Management API. To learn how to modify the connection to use your own SMS gateway, see Configure SMS Gateway for Passwordless Connections.

Configure passwordless SMS settings

  1. In Message, enter the body text of the SMS.

The @@password@@ placeholder will automatically be replaced with the one-time password that is sent to the user.

  1. Adjust settings for your OTP Expiry and OTP Length.
  • Only the last one-time password (or link) issued will be accepted. Once the latest one is issued, any others are invalidated. Once used, the latest one is also invalidated.
  • Only three failed attempts to input the one-time password are allowed. After this, a new code will need to be requested.
  • The one-time password issued will be valid (by default) for three minutes before it expires.
  • If you choose to extend the amount of time it takes for your one-time password to expire, you should also extend the length of the one-time password code. Otherwise, an attacker has a larger window of time to attempt to guess a short code.
  1. Decide if you want to Disable Signups. You can enable passwordless access just for existing users by enabling this setting.

  2. Click Save.

Multi-language support

The Message area supports multiple languages.

To choose the language, call the /passwordless/start authentication endpoint and set the value of the 'x-request-language' header. When this header is not set, the language is extracted from the 'accept-language' header, which is automatically set by the browser.

Message syntax

The Message area accepts Liquid syntax. You can use this syntax, combined with exposed parameter values, to programmatically construct elements of the message. For example, you can reference the request_language parameter to change the language of the message:

{% if request_language contains 'dutch' %}
   Hier is uw verificatie code: {{ password }}
{% endif %}

{% if request_language contains 'fr-FR' %}
   Ceci est votre code: {{ password }}
{% endif %}

The following parameters are available when defining the message template:

Exposed Parameter Description
password or code The password to use
phone_number The user's phone number The name of the application with which the user is signing up
request_language The requested language for message content

Enable your apps

Select the Applications view, and enable the applications for which you would like to use Passwordless SMS.