OAuth 2.0 and OpenID Connect error codes
OAuth and OpenID Connect define a compact set of machine-readable error codes returned across the authorization, token, resource-server, and device-flow endpoints. Each error value (often paired with error_description and error_uri) tells the client exactly what went wrong — a malformed request, a failed client authentication, an expired grant, or a need for user interaction. Knowing the difference between invalid_client and invalid_grant, or between login_required and consent_required, saves hours of integration debugging. Search the reference above by code or keyword.
How it works
Errors arrive in one of two shapes depending on the endpoint. The authorization endpoint redirects back to the client with error, error_description, and state in the query (or fragment), using codes like access_denied and unsupported_response_type. The token endpoint returns a JSON body with an error field and typically an HTTP 400 (or 401 for invalid_client), using codes like invalid_grant and unsupported_grant_type. Resource servers signal invalid_token (401) and insufficient_scope (403) via the WWW-Authenticate header per RFC 6750. OpenID Connect adds interaction errors (login_required, consent_required) for silent prompt=none requests, and the device flow (RFC 8628) adds polling errors (authorization_pending, slow_down).
Tips and examples
- Treat
invalid_grantas “start over”: clear the stored refresh token and send the user back through authorization rather than retrying the same grant. - Map
invalid_clientto a configuration problem — wrong client ID/secret or auth method — not a user problem. - In silent SSO, expect
login_required/interaction_requiredand fall back to an interactiveprompt=logininstead of failing the user. - In the device flow, always honor
slow_downby widening your poll interval, and stop polling onexpired_tokento begin a fresh request.