Availability varies by Auth0 plan
Both your specific login implementation and your Auth0 plan or custom agreement affect whether this feature is available. To learn more, read Pricing.
Prerequisites
Before you can use the MFA APIs, you’ll need to enable the MFA grant type for your application. Go to Auth0 Dashboard > Applications > Advanced Settings > Grant Types and select MFA.- Configure Email as a factor in the Dashboard or using the Management API.
Enroll with email
To enable users to enroll emails in addition to their verified email in their primary identity, you need to complete the following steps.Get MFA token
Depending on when you are triggering enrollment, you can obtain an for using the MFA API in different ways:- If you are enrolling during authentication, see Authenticate With Resource Owner Password Grant and MFA.
- If you want to let the user enroll a factor at any moment, see Manage MFA Factor Enrollments.
Enroll authenticator
Make aPOST
request to the MFA Associate endpoint to enroll the user’s authenticator. The bearer token required by this endpoint is the MFA token obtained in the previous step.
Use the following parameters:
Parameter | Value |
---|---|
authentication_types | [oob] |
oob_channels | [email] |
email | email@address.com , the users email address. |
User is already enrolled
error, the user already has an MFA factor enrolled. Before associating another factor with the user, you must challenge the user with the existing factor.
If this is the first time the user is associating an authenticator, you’ll notice the response includes recovery_codes
. Recovery codes are used to access the user’s account in the event that they lose access to the account or device used for their second-factor authentication. These are one-time usable codes, and new ones are generated as necessary.
Confirm email enrollment
The user should receive an email containing the 6-digit code that they can provide to the application. To complete the enrollment, make aPOST
request to the /oath/token
endpoint. Include the oob_code
returned in the previous response and the binding_code
with the value in the email message.
active
is true
.
Optionally, you can customize the emails that users receive. See Customize Email Templates for details.
Challenge with email
Get MFA token
Get an MFA token following the steps described in Authenticate With Resource Owner Password Grant and MFA.Retrieve enrolled authenticators
To challenge the user, you need theauthenticator_id
for the factor you want to challenge. You can list all enrolled authenticators using the MFA Authenticators endpoint:
Challenge user with OTP
To trigger an email challenge,POST
to the MFA Challenge endpoint using the corresponding authenticator_id
and the mfa_token
.
Complete authentication using received code
If successful, you receive the following response:binding_code
parameter in the following call to the oauth``/token
endpoint: