Documentation Index
Fetch the complete documentation index at: https://mintlify.com/auth0/nextjs-auth0/llms.txt
Use this file to discover all available pages before exploring further.
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
Always
"invalid_request"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
Auth0 error code (e.g.,
"invalid_token", "expired_token").Human-readable error description from Auth0.
Same as
error property. Use this for programmatic error handling.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
Auth0 error code (e.g.,
"invalid_authenticator_id", "unsupported_challenge_type").Human-readable error description from Auth0.
Same as
error property. Use this for programmatic error handling.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
Auth0 error code (e.g.,
"invalid_grant", "invalid_otp").Human-readable error description from Auth0.
Same as
error property. Use this for programmatic error handling.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
Always
"mfa_no_available_factors"Always
"mfa_no_available_factors"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
Auth0 error code (e.g.,
"unsupported_challenge_type", "invalid_token").Human-readable error description from Auth0.
Same as
error property. Use this for programmatic error handling.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
Always
"mfa_required"Always
"mfa_required"Error description from Auth0.
Encrypted MFA token to pass to MFA API methods. This token is encrypted using the SDK’s cookie secret for security.
MFA requirements indicating available challenge/enrollment methods.
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
Always
"mfa_token_expired"“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
Always
"mfa_token_invalid"“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
| Error Code | Description | Recovery Action |
|---|---|---|
invalid_token | MFA token is invalid or expired | Restart authentication flow |
expired_token | MFA token has expired | Restart authentication flow |
invalid_grant | Invalid verification code or OTP | Prompt user to re-enter code |
invalid_authenticator_id | Authenticator not found or inactive | Show list of available authenticators |
unsupported_challenge_type | Challenge type not supported | Use a different authenticator type |
invalid_otp | One-time password is incorrect | Allow user to retry |
too_many_attempts | Too many failed verification attempts | Implement rate limiting or cooldown |
Related
- SdkError - Base error class
- OAuth Errors - OAuth 2.0 related errors
- Auth0 MFA API Documentation