Overview
OAuth errors are thrown during various stages of the OAuth 2.0 and OpenID Connect authentication flows. All OAuth error classes extend fromSdkError and can be caught using their specific error codes.
OAuth2Error
Generic OAuth 2.0 error from the authorization server. This error may contain reflected user input via OpenID Connecterror and error_description query parameters.
Properties
The OAuth 2.0 error code from the authorization server (e.g.,
"access_denied", "invalid_grant", "server_error").Error message from the authorization server or the default message: “An error occurred while interacting with the authorization server.”
Usage
DiscoveryError
Thrown when the SDK fails to retrieve the OpenID Connect configuration from the authorization server’s discovery endpoint.Properties
Always
"discovery_error"Default: “Discovery failed for the OpenID Connect configuration.”
When Thrown
- The authorization server’s
.well-known/openid-configurationendpoint is unreachable - The discovery response is malformed or invalid
- Network connectivity issues during discovery
Example
MissingStateError
Thrown when the OAuth callback is missing the requiredstate parameter.
Properties
Always
"missing_state"Default: “The state parameter is missing.”
When Thrown
- The authorization server callback doesn’t include a
stateparameter - The callback URL was manipulated or corrupted
InvalidStateError
Thrown when the OAuth callback’sstate parameter doesn’t match the expected value stored in the transaction.
Properties
Always
"invalid_state"Default: “The state parameter is invalid.”
When Thrown
- CSRF attack attempt detected
- State parameter was modified
- Transaction cookie expired or was cleared
- Multiple concurrent login attempts from the same browser
Example
InvalidConfigurationError
Thrown when the SDK is initialized with invalid configuration options.Properties
Always
"invalid_configuration"Default: “The configuration is invalid.”
When Thrown
- Missing required environment variables (
AUTH0_DOMAIN,AUTH0_CLIENT_ID,AUTH0_CLIENT_SECRET,AUTH0_SECRET) - Invalid configuration values (e.g., malformed URLs, invalid algorithm)
- Incompatible configuration combinations
Example
AuthorizationError
Thrown when an error occurs during the authorization flow. Contains the underlyingOAuth2Error as its cause.
Properties
Always
"authorization_error"The underlying OAuth 2.0 error from the authorization server.
Default: “An error occurred during the authorization flow.”
When Thrown
- User denies authorization
- Invalid scopes requested
- Authorization server configuration issues
Example
AuthorizationCodeGrantRequestError
Thrown when preparing or performing the authorization code grant request fails.Properties
Always
"authorization_code_grant_request_error"Default: “An error occurred while preparing or performing the authorization code grant request.”
When Thrown
- Network errors during token exchange
- Invalid request format
- Authorization server unreachable
AuthorizationCodeGrantError
Thrown when the authorization code exchange fails. Contains the underlyingOAuth2Error as its cause.
Properties
Always
"authorization_code_grant_error"The underlying OAuth 2.0 error from the token endpoint.
Default: “An error occurred while trying to exchange the authorization code.”
When Thrown
- Invalid authorization code
- Expired authorization code
- Code already used (replay attack)
- Code verifier mismatch (PKCE)
Example
BackchannelLogoutError
Thrown when completing a backchannel logout request fails.Properties
Always
"backchannel_logout_error"Default: “An error occurred while completing the backchannel logout request.”
When Thrown
- Invalid logout token
- Signature verification fails
- Session not found
BackchannelAuthenticationNotSupportedError
Thrown when attempting to use Client-Initiated Backchannel Authentication (CIBA) but the authorization server doesn’t support it.Properties
Always
"backchannel_authentication_not_supported_error"“The authorization server does not support backchannel authentication. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-client-initiated-backchannel-authentication”
When Thrown
- CIBA is not enabled in your Auth0 tenant
- OIDC discovery doesn’t include backchannel authentication endpoint
Example
BackchannelAuthenticationError
Thrown when a Client-Initiated Backchannel Authentication request fails.Properties
Always
"backchannel_authentication_error"The underlying OAuth 2.0 error, if available.
“There was an error when trying to use Client-Initiated Backchannel Authentication.”
When Thrown
- Invalid login hint
- User not found
- Authentication device not available
AccessTokenError
Thrown when retrieving or refreshing an access token fails. See Access Token Error Codes for specific error codes.Properties
One of:
"missing_session", "missing_refresh_token", or "failed_to_refresh_token"Error-specific message describing what went wrong.
The underlying OAuth 2.0 error when
code is "failed_to_refresh_token".Access Token Error Codes
When Thrown
missing_session: No active session exists (user not logged in)missing_refresh_token: Session exists but doesn’t contain a refresh token (offline_access scope not requested)failed_to_refresh_token: Token refresh request failed (expired refresh token, revoked token, network error)
Example
AccessTokenForConnectionError
Thrown when retrieving or exchanging an access token for a specific connection fails.Properties
One of:
"missing_session", "missing_refresh_token", or "failed_to_exchange_refresh_token"Error-specific message describing what went wrong.
The underlying OAuth 2.0 error when exchange fails.
Error Codes
Example
CustomTokenExchangeError
Thrown when a custom token exchange operation fails.Properties
One of:
"missing_subject_token", "invalid_subject_token_type", "missing_actor_token_type", or "exchange_failed"Error-specific message describing the validation failure or exchange error.
The underlying OAuth 2.0 error when exchange fails.
Error Codes
When Thrown
missing_subject_token: Thesubject_tokenis missing or emptyinvalid_subject_token_type: Thesubject_token_typeis not a valid URI, wrong length, or uses a reserved namespacemissing_actor_token_type: Theactor_tokenwas provided withoutactor_token_typeexchange_failed: The token exchange request failed
Example
Related
- SdkError - Base error class
- DPoP Errors - DPoP-specific errors
- MFA Errors - Multi-factor authentication errors