Overview
MFA (Multi-Factor Authentication) errors are thrown during MFA enrollment, challenge, and verification operations. All MFA error classes extend fromSdkError and follow the Auth0 API error format with error and error_description properties.
MFA errors support both direct SDK consumption and HTTP API route usage via automatic
toJSON() serialization.Error Response Format
All MFA errors follow the Auth0 MFA API error response format:InvalidRequestError
Thrown when MFA request validation fails due to missing or invalid parameters.Properties
string
required
Always
"invalid_request"string
required
Description of the validation failure.
When Thrown
- Missing required parameters (
mfaToken,otp,authenticatorId, etc.) - Invalid parameter formats or values
- Parameter type mismatches
Example
MfaGetAuthenticatorsError
Thrown when listing MFA authenticators fails.Properties
string
required
Auth0 error code (e.g.,
"invalid_token", "expired_token").string
required
Human-readable error description from Auth0.
string
required
Same as
error property. Use this for programmatic error handling.MfaApiErrorResponse | undefined
The original Auth0 API error response.
When Thrown
- Invalid or expired MFA token
- MFA token doesn’t belong to the current session
- Network errors communicating with Auth0
Example
MfaChallengeError
Thrown when initiating an MFA challenge fails.Properties
string
required
Auth0 error code (e.g.,
"invalid_authenticator_id", "unsupported_challenge_type").string
required
Human-readable error description from Auth0.
string
required
Same as
error property. Use this for programmatic error handling.MfaApiErrorResponse | undefined
The original Auth0 API error response.
When Thrown
- Invalid or expired MFA token
- Authenticator ID not found or not active
- Challenge type not supported for the authenticator
- User doesn’t own the authenticator
Example
MfaVerifyError
Thrown when MFA verification fails.Properties
string
required
Auth0 error code (e.g.,
"invalid_grant", "invalid_otp").string
required
Human-readable error description from Auth0.
string
required
Same as
error property. Use this for programmatic error handling.MfaApiErrorResponse | undefined
The original Auth0 API error response.
When Thrown
- Invalid or expired verification code
- Wrong OTP entered
- Too many verification attempts
- Expired MFA token
Example
MfaNoAvailableFactorsError
SDK-generated error thrown when no MFA factors are available for challenge. This error has no Auth0 API equivalent.Properties
string
required
Always
"mfa_no_available_factors"string
required
Always
"mfa_no_available_factors"string
required
Description of why no factors are available.
When Thrown
- User has no enrolled authenticators
- All authenticators are inactive or unavailable
- Challenge type requested has no matching authenticators
Example
MfaEnrollmentError
Thrown when MFA enrollment fails.Properties
string
required
Auth0 error code (e.g.,
"unsupported_challenge_type", "invalid_token").string
required
Human-readable error description from Auth0.
string
required
Same as
error property. Use this for programmatic error handling.MfaApiErrorResponse | undefined
The original Auth0 API error response.
When Thrown
- Unsupported authenticator type for the tenant
- Invalid MFA token
- Enrollment already exists
- Maximum authenticators reached
Example
MfaRequiredError
Thrown whengetAccessToken() requires MFA step-up authentication. This error is returned during token refresh when Auth0 indicates that MFA is required.
Properties
string
required
Always
"mfa_required"string
required
Always
"mfa_required"string
required
Error description from Auth0.
string
required
Encrypted MFA token to pass to MFA API methods. This token is encrypted using the SDK’s cookie secret for security.
MfaRequirements | undefined
MFA requirements indicating available challenge/enrollment methods.
Error | undefined
The underlying error that caused this MFA requirement.
MfaRequirements Type
When Thrown
- Access token refresh requires MFA step-up
- Tenant has MFA policies requiring additional authentication
- High-risk actions require MFA verification
Example
Complete MFA Step-Up Flow
MfaTokenExpiredError
Thrown when MFA API methods are called but the encryptedmfa_token has expired or the session context no longer exists.
Properties
string
required
Always
"mfa_token_expired"string
required
“MFA token has expired. Please restart the MFA flow.”
When Thrown
- The session expired between catching
MfaRequiredErrorand calling MFA methods - The MFA context was cleaned up due to TTL expiration
- Too much time passed between MFA steps
Example
MfaTokenInvalidError
Thrown when the encryptedmfa_token is invalid or tampered with.
Properties
string
required
Always
"mfa_token_invalid"string
required
“MFA token is invalid.”
When Thrown
- The token was tampered with
- The token is malformed (not valid JWE)
- The token was encrypted with a different secret
- The token doesn’t belong to the current session
Example
Error Handling Best Practices
Catching Errors in API Routes
MFA errors serialize automatically for HTTP responses:Catching by Error Code
Common MFA Error Codes from Auth0
Related
- SdkError - Base error class
- OAuth Errors - OAuth 2.0 related errors
- Auth0 MFA API Documentation