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
string
required
The OAuth 2.0 error code from the authorization server (e.g.,
"access_denied", "invalid_grant", "server_error").string
required
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
string
required
Always
"discovery_error"string
required
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
string
required
Always
"missing_state"string
required
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
string
required
Always
"invalid_state"string
required
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
string
required
Always
"invalid_configuration"string
required
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
string
required
Always
"authorization_error"OAuth2Error
required
The underlying OAuth 2.0 error from the authorization server.
string
required
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
string
required
Always
"authorization_code_grant_request_error"string
required
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
string
required
Always
"authorization_code_grant_error"OAuth2Error
required
The underlying OAuth 2.0 error from the token endpoint.
string
required
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
string
required
Always
"backchannel_logout_error"string
required
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
string
required
Always
"backchannel_authentication_not_supported_error"string
required
“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
string
required
Always
"backchannel_authentication_error"OAuth2Error | undefined
The underlying OAuth 2.0 error, if available.
string
required
“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
string
required
One of:
"missing_session", "missing_refresh_token", or "failed_to_refresh_token"string
required
Error-specific message describing what went wrong.
OAuth2Error | undefined
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
string
required
One of:
"missing_session", "missing_refresh_token", or "failed_to_exchange_refresh_token"string
required
Error-specific message describing what went wrong.
OAuth2Error | undefined
The underlying OAuth 2.0 error when exchange fails.
Error Codes
Example
CustomTokenExchangeError
Thrown when a custom token exchange operation fails.Properties
string
required
One of:
"missing_subject_token", "invalid_subject_token_type", "missing_actor_token_type", or "exchange_failed"string
required
Error-specific message describing the validation failure or exchange error.
OAuth2Error | undefined
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