API Error Handling
Applications integrating with Zanthem Identity Services must handle unsuccessful authentication requests, invalid credentials, expired sessions, and other service errors.
Authentication endpoints use standard OAuth 2.0 and OpenID Connect error formats where applicable.
Error Response Format
Token and other API endpoints may return a JSON response containing error information.
Example Response
{
"error": "invalid_grant",
"error_description": "Invalid or expired authorization code"
}
Response Fields
| Field | Description |
|---|---|
error | Machine-readable error identifier. |
error_description | Optional human-readable error description. |
error_uri | Optional reference to additional error information. |
state | Original request state, where applicable to authorization responses. |
Applications should use the machine-readable
error value when implementing error handling.
Error descriptions are intended for diagnostic purposes and should not be treated as stable identifiers.
HTTP Status Codes
| Status | Description |
|---|---|
200 OK | Request completed successfully. |
302 Found | Redirect associated with an authentication operation. |
400 Bad Request | Missing or invalid request parameters. |
401 Unauthorized | Invalid authentication credentials or access token. |
403 Forbidden | Request is not permitted. |
404 Not Found | Requested endpoint or realm could not be located. |
405 Method Not Allowed | Unsupported HTTP request method. |
429 Too Many Requests | Request rate exceeded an applicable limit. |
500 Internal Server Error | Unexpected server-side error. |
502 Bad Gateway | Upstream connectivity or gateway failure. |
503 Service Unavailable | Service temporarily unavailable. |
504 Gateway Timeout | Upstream request timed out. |
Not every status code applies to every endpoint.
Gateway and infrastructure errors may return non-JSON responses.
OAuth 2.0 Errors
| Error | Description |
|---|---|
invalid_request | Request is malformed or contains missing or invalid parameters. |
invalid_client | Client authentication failed. |
invalid_grant | Authorization code or refresh token is invalid, expired, revoked, or otherwise unacceptable. |
unauthorized_client | Application is not authorized to use the requested authentication flow. |
unsupported_grant_type | Requested grant type is not supported. |
unsupported_response_type | Requested authorization response type is not supported. |
invalid_scope | Requested scope is invalid or not permitted. |
access_denied | Authorization request was denied. |
server_error | Authentication service encountered an unexpected error. |
temporarily_unavailable | Authentication service is temporarily unable to process the request. |
OpenID Connect Errors
| Error | Description |
|---|---|
login_required | Interactive authentication is required. |
interaction_required | Additional user interaction is required. |
consent_required | User consent is required. |
account_selection_required | User account selection is required. |
These errors may occur during authentication requests that attempt to proceed without interactive user involvement.
Protected Resource Errors
| Error | Description |
|---|---|
invalid_token | Access token is missing, expired, revoked, or otherwise invalid. |
insufficient_scope | Access token does not provide the required scope. |
Protected endpoints may return additional
authentication information through the
WWW-Authenticate response header.
Authorization Errors
Errors occurring during an authorization request may be returned through the registered callback URI.
Example Response
https://app.example.com/callback
?error=access_denied
&error_description=Authorization%20request%20denied
&state=GENERATED_STATE
Applications must validate returned state values before processing the authentication response.
If the callback URI itself is invalid, the authentication service may display an error instead of redirecting the user.
Common Integration Issues
Invalid Client
Error:
invalid_client
Possible causes:
- Incorrect client identifier.
- Incorrect or expired client secret.
- Unsupported client authentication method.
- Client belongs to a different realm.
- Application client is disabled.
Resolution:
Verify the application configuration against the integration information supplied by your account manager.
Confirm that confidential client credentials are being transmitted using the approved authentication method.
Invalid Grant
Error:
invalid_grant
Possible causes:
- Authorization code has expired.
- Authorization code has already been used.
- Refresh token has expired or been revoked.
- Incorrect PKCE verifier.
- Redirect URI differs from the authorization request.
- Authorization code was issued to a different client.
Resolution:
Initiate a new authentication transaction where necessary.
Verify that the original PKCE verifier and redirect URI are supplied during the authorization code exchange.
Do not repeatedly retry an invalid authorization code.
Invalid Redirect URI
Possible causes:
- Redirect URI is not registered.
- Incorrect application domain.
- Incorrect callback path.
- HTTP and HTTPS mismatch.
- Unexpected trailing slash.
- Incorrect development or production environment.
Resolution:
Confirm the callback URI against the approved configuration provided during onboarding.
Contact your account manager if additional callback addresses are required.
Invalid Scope
Error:
invalid_scope
Possible causes:
- Requested scope is not available.
- Requested scope is not assigned to the client.
- Incorrect scope formatting.
- Application requests permissions outside its approved configuration.
Resolution:
Verify the scopes assigned to the application.
Contact your account manager if additional scopes are required.
Unauthorized Client
Error:
unauthorized_client
Possible causes:
- Requested authentication flow is not enabled.
- Client Credentials flow is not authorized.
- Application is attempting to use a restricted grant.
Resolution:
Verify that the application is using the authentication flow established during onboarding.
Invalid or Expired Access Token
Possible causes:
- Access token has expired.
- Token signature is invalid.
- Token was issued by a different realm.
- Token audience does not match the resource.
- Token has been revoked.
- Authorization header is missing or malformed.
Resolution:
Verify the access token and its intended audience.
Refresh the access token where appropriate.
If the session cannot be recovered, initiate a new authentication transaction.
Signing Key Validation Failure
Possible causes:
- Cached signing keys are outdated.
- Token was issued by a different realm.
- Unexpected token signing algorithm.
- Invalid or untrusted token signature.
Resolution:
Verify the configured issuer URL and retrieve the current public signing keys through the discovery document's JWKS endpoint.
Never bypass signature verification to resolve a signing key validation failure.
Request Retry Behavior
Applications should distinguish temporary service failures from permanent request failures.
| Error Type | Recommended Behavior |
|---|---|
| Invalid request parameters | Correct the request before retrying. |
| Invalid client credentials | Verify configuration before retrying. |
| Expired access token | Attempt token refresh where appropriate. |
| Invalid refresh token | Initiate a new authentication transaction. |
| Rate limiting | Respect Retry-After when provided. |
| Temporary service failure | Use bounded exponential backoff where safe. |
Authorization codes are single-use credentials.
Avoid blindly repeating token exchange or refresh requests after an ambiguous network failure, as the original request may have already succeeded.
Applications should prevent uncontrolled retry loops.
Diagnostic Logging
When troubleshooting an integration, applications should record relevant non-sensitive diagnostic information.
Recommended diagnostic information includes:
- Request timestamp in UTC
- Application client identifier
- Assigned realm
- Endpoint being accessed
- HTTP response status
- Machine-readable error identifier
- Sanitized error description
- Request or correlation identifier, when available
- Application environment
Do not include sensitive credentials in diagnostic logs.
:::warning Sensitive information
Never include the following in diagnostic logs or ordinary support communications:
- Client secrets
- User passwords
- Authorization codes
- Access tokens
- Refresh tokens
- ID tokens
- PKCE verifiers
- Private keys
- Authentication cookies
- Unnecessary personal information
:::
Contacting Support
If an issue cannot be resolved through the documentation, contact your assigned Zanthem account manager.
Include the relevant sanitized diagnostic information and a description of the issue.
For persistent issues, indicate:
- When the problem first occurred.
- Whether the integration previously worked.
- Which application environments are affected.
- Whether all users or specific users are affected.
- Whether recent application changes were made.
Suspected security incidents or credential exposure should be reported immediately.