Initiates an MFA challenge
Sends OTP via SMS, initiates push notification, or prepares for OTP entry
Challenge parameters including mfaToken
Challenge response with oobCode if applicable
Enrolls a new MFA authenticator
Requires MFA access token with 'enroll' scope
Enrollment parameters including mfaToken and factorType
Enrollment response with authenticator details
Gets enrolled MFA authenticators filtered by challenge types from context.
Challenge types are automatically resolved from the stored MFA context (set when mfa_required error occurred).
MFA token from mfa_required error
Array of enrolled authenticators matching the challenge types
Gets available MFA enrollment factors from the stored context.
This method exposes the enrollment options from the mfa_required error's mfaRequirements.enroll array, eliminating the need for manual parsing.
MFA token from mfa_required error
Array of enrollment factors available for the user (empty array if no enrollment required)
try {
await auth0.getTokenSilently();
} catch (error) {
if (error.error === 'mfa_required') {
// Get enrollment options from SDK
const enrollOptions = await auth0.mfa.getEnrollmentFactors(error.mfa_token);
// [{ type: 'otp' }, { type: 'phone' }, { type: 'push-notification' }]
showEnrollmentOptions(enrollOptions);
}
}
try {
const factors = await auth0.mfa.getEnrollmentFactors(mfaToken);
if (factors.length > 0) {
// User needs to enroll in MFA
renderEnrollmentUI(factors);
} else {
// No enrollment required, proceed with challenge
}
} catch (error) {
if (error instanceof MfaEnrollmentFactorsError) {
console.error('Context not found:', error.error_description);
}
}
InternalStores authentication details (scope, audience, and MFA requirements) for MFA token verification. This is automatically called by Auth0Client when an mfa_required error occurs.
The context is stored keyed by the MFA token, enabling concurrent MFA flows.
The MFA token from the mfa_required error response
Optionalscope: stringThe OAuth scope from the original request (optional)
Optionalaudience: stringThe API audience from the original request (optional)
OptionalmfaRequirements: MfaRequirementsThe MFA requirements from the mfa_required error (optional)
Verifies an MFA challenge and completes authentication
The scope and audience are retrieved from the stored context (set when the mfa_required error occurred). The grant_type is automatically inferred from which verification field is provided (otp, oobCode, or recoveryCode).
Verification parameters with OTP, OOB code, or recovery code
Token response with access_token, id_token, refresh_token
If grant_type cannot be inferred
Rate limits:
const tokens = await mfa.verify({
mfaToken: mfaTokenFromLogin,
otp: '123456'
});
console.log(tokens.access_token);
Client for Auth0 MFA API operations
Manages multi-factor authentication including:
This is a wrapper around auth0-auth-js MfaClient that maintains backward compatibility with the existing spa-js API.
MFA context (scope, audience) is stored internally keyed by mfaToken, enabling concurrent MFA flows without state conflicts.
Example