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.Authenticate user
When you use the Resource Owner Password Flow to authenticate, you call the/oauth/token
endpoint with the user’s username and password.
mfa_required
error and a mfa_token
.
The default expiry time of access tokens with the
https://{yourDomain}/mfa/*
audience is 10 minutes. This value cannot be configured.Retrieve enrolled authenticators
After getting the error above, you need to find out if the user has an MFA factor enrolled or not. Call the MFA Authenticators endpoint, using the MFA token obtained in the previous section.Enroll MFA factor
If the user is not enrolled in MFA, use the MFA token obtained earlier and enroll it using the MFA Associate endpoint. See the following links to implement this flow based on the authentication factor:Challenge user with MFA
If the user is already enrolled in MFA, you need to challenge the user with one of the existing factors. Use theauthenticator_id
return by the MFA Authenticators endpoint when calling the MFA Challenge endpoint.
After the challenge is complete, call /oauth/token
endpoint again to finalize the authentication flow and get the authentication tokens.
See the links below to implement this flow depending on the authentication factor: