Skip to main content

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​

FieldDescription
errorMachine-readable error identifier.
error_descriptionOptional human-readable error description.
error_uriOptional reference to additional error information.
stateOriginal 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​

StatusDescription
200 OKRequest completed successfully.
302 FoundRedirect associated with an authentication operation.
400 Bad RequestMissing or invalid request parameters.
401 UnauthorizedInvalid authentication credentials or access token.
403 ForbiddenRequest is not permitted.
404 Not FoundRequested endpoint or realm could not be located.
405 Method Not AllowedUnsupported HTTP request method.
429 Too Many RequestsRequest rate exceeded an applicable limit.
500 Internal Server ErrorUnexpected server-side error.
502 Bad GatewayUpstream connectivity or gateway failure.
503 Service UnavailableService temporarily unavailable.
504 Gateway TimeoutUpstream request timed out.

Not every status code applies to every endpoint.

Gateway and infrastructure errors may return non-JSON responses.

OAuth 2.0 Errors​

ErrorDescription
invalid_requestRequest is malformed or contains missing or invalid parameters.
invalid_clientClient authentication failed.
invalid_grantAuthorization code or refresh token is invalid, expired, revoked, or otherwise unacceptable.
unauthorized_clientApplication is not authorized to use the requested authentication flow.
unsupported_grant_typeRequested grant type is not supported.
unsupported_response_typeRequested authorization response type is not supported.
invalid_scopeRequested scope is invalid or not permitted.
access_deniedAuthorization request was denied.
server_errorAuthentication service encountered an unexpected error.
temporarily_unavailableAuthentication service is temporarily unable to process the request.

OpenID Connect Errors​

ErrorDescription
login_requiredInteractive authentication is required.
interaction_requiredAdditional user interaction is required.
consent_requiredUser consent is required.
account_selection_requiredUser account selection is required.

These errors may occur during authentication requests that attempt to proceed without interactive user involvement.

Protected Resource Errors​

ErrorDescription
invalid_tokenAccess token is missing, expired, revoked, or otherwise invalid.
insufficient_scopeAccess 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 TypeRecommended Behavior
Invalid request parametersCorrect the request before retrying.
Invalid client credentialsVerify configuration before retrying.
Expired access tokenAttempt token refresh where appropriate.
Invalid refresh tokenInitiate a new authentication transaction.
Rate limitingRespect Retry-After when provided.
Temporary service failureUse 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.