Skip to content

OAuth and OIDC error code lookup

Look up an OAuth 2.0 or OpenID Connect error code, or paste an error response, to see what it means and what usually causes it.

Runs in your browser. Nothing you paste is sent to us.

Error

Type a code such as invalid_client, or paste the JSON error or the URL your app got. A sample is filled in.

error invalid_grant Code not valid

Keycloak message
invalid_grant
Code not validThe authorization code was already used, has expired, or belongs to another client.
Messages Keycloak often returns
shown on an error page
Invalid parameter: redirect_uriThe redirect_uri does not match any of the client’s Valid redirect URIs. Keycloak shows an error page instead of redirecting, because the URI is not trusted.
invalid_grant
Code not validThe authorization code was already used, has expired, or belongs to another client.
invalid_grant
Invalid user credentialsA password grant with a wrong username or password.
invalid_grant
Session not activeThe user session behind the code or refresh token has ended or expired.
invalid_grant
Token is not activeThe refresh token has expired.
invalid_client
Invalid client or Invalid client credentialsUnknown client_id in this realm, or a wrong client secret.
unauthorized_client
Client not allowed for direct access grantsA password grant for a client where Direct access grants is off.
invalid_grant
Account is not fully set upThe user has a required action pending, such as updating a password or verifying an email, which a password grant cannot complete.
invalid_request
Missing parameter: code_challenge_methodThe client requires PKCE and the authorization request had no code_challenge_method.
unauthorized_client
Client not enabled to retrieve service accountA client credentials grant for a client where Service accounts roles is off.
—
Offline tokens not allowed for the user or clientoffline_access was requested, but the user lacks the offline_access role or the client cannot get it.

Codes (1)

invalid_grant

The code, refresh token, device code or credentials are invalid, expired, revoked, already used, or were issued to another client.

returned by
Token response
defined in
RFC 6749 5.2
usual causes
  • The authorization code was used twice or has expired. Codes are short-lived and single-use.
  • The redirect_uri differs from the one in the authorization request.
  • The PKCE code_verifier does not match the code_challenge.
  • The refresh token expired, or the session behind it ended.

How to use it

  1. Type an error code such as invalid_grant, or part of one.
  2. Or paste the JSON error or the callback URL; the code is read from it.
  3. Read the meaning, where it is returned, and the usual causes.

What to know

The codes come from RFC 6749 (OAuth 2.0), RFC 6750 (bearer tokens), OpenID Connect Core 1.0, RFC 8628 (device flow), RFC 7009 (revocation), RFC 8693 (token exchange), RFC 9449 (DPoP) and others.

The error code says what kind of problem it is. error_description says more, and Keycloak’s descriptions often name the cause directly.

The list of common Keycloak messages pairs the descriptions we see most with their usual cause.

How OAuth reports errors

OAuth 2.0 errors are short, fixed codes such as invalid_grant or invalid_client. RFC 6749 defines the first set, and later specifications add their own. The code tells your program what kind of problem it is. An optional error_description gives a human-readable reason, and an optional error_uri points to a page about it.

Where the error appears depends on the endpoint. The same code can mean slightly different things in different places, so it helps to know which request produced it.

From the authorization endpoint

Errors in the browser flow come back as parameters on the redirect to your app, usually in the query string. RFC 6749 section 4.1.2.1 defines them. If the server cannot trust the redirect URI or the client id, it does not redirect at all and shows an error page instead.

Sample error redirect (made-up values)
https://app.example.com/callback?error=login_required&error_description=Login+required&state=Zq3v8sample7KpW2

From the token endpoint

Errors from back-channel requests come as a JSON body, usually with HTTP 400, or 401 for a failed client authentication. RFC 6749 section 5.2 defines them.

Sample token error response (made-up values)
HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": "invalid_grant",
  "error_description": "Code not valid"
}

From an API

An API that rejects a bearer token answers 401 or 403 with a WWW-Authenticate header, as RFC 6750 section 3 describes. The header carries error="invalid_token" or error="insufficient_scope".

What this tool does

The lookup holds the error codes from RFC 6749, RFC 6750, OpenID Connect Core 1.0, RFC 8628 (device flow), RFC 7009 (revocation), RFC 8693 (token exchange), RFC 8707 (resource indicators), RFC 9449 (DPoP), RFC 9396 (rich authorization requests) and RFC 7591 (dynamic client registration). For each code it shows the meaning, where it is returned, the section that defines it and the usual causes.

You can type a code or part of one, or paste a whole JSON error or callback URL. The tool reads error and error_description out of what you paste. If the description is one of the messages Keycloak often returns, it shows that message and its usual cause too.

It does not contact any server or read your logs. A code tells you the category of the problem; the server’s logs tell you the exact cause.

How to use it

  1. Copy the error your app received: the JSON body, the callback URL or just the code.
  2. Paste it into the box.
  3. Read the meaning and the list of usual causes.
  4. If a Keycloak message appears, read its cause; it is usually more specific.
  5. Fix the cause, then repeat the whole flow from the start. Codes and device codes cannot be reused after an error.

The errors you will meet most

invalid_grant

The grant itself is bad. For the code flow, the code was already used, has expired, or was issued to another client. The redirect_uri in the token request must also equal the one in the authorization request, and the PKCE code_verifier must match the challenge. For a refresh, the refresh token expired or its session ended.

invalid_client

Client authentication failed. Check the client id, the realm, the secret and the authentication method. A client set up for a signed JWT will reject a secret, and the other way round.

unauthorized_client

The client authenticated but may not use this grant. In Keycloak, the flow is switched off on the client: Standard flow, Direct access grants, Service accounts roles or the device grant.

invalid_scope

A requested scope does not exist or is not available to the client. Scopes are separated by spaces, not commas.

login_required and interaction_required

These come from a silent request with prompt=none. The user has no session, or must do something first. Send the user through a normal sign-in.

PKCE errors

When a client requires PKCE and the authorization request has no challenge, the server answers invalid_request on the redirect. When the challenge was sent but the token request has no verifier, or the wrong one, the token endpoint answers invalid_grant. The usual cause is a verifier lost between the redirect and the callback, for example when it was kept in memory and the page reloaded.

DPoP errors

invalid_dpop_proof means the proof is missing, badly signed or does not match the request: check htm, htu, the clock and, for API calls, ath. use_dpop_nonce means the server wants a nonce; repeat the request with the value from the DPoP-Nonce response header (RFC 9449).

Device flow polling codes

authorization_pending is normal while the user is still signing in. slow_down means add 5 seconds to the polling interval. access_denied means the user declined, and expired_token means the device code ran out; start again.

Messages Keycloak often returns

Keycloak’s error_description texts often name the cause directly. These are the ones we see most:

DescriptionUsual cause
Invalid parameter: redirect_uriThe redirect URI matches none of the client’s Valid redirect URIs. Shown on an error page.
Code not validThe code was used before, has expired, or belongs to another client.
Session not activeThe user session behind the code or refresh token ended.
Token is not activeThe refresh token has expired.
Invalid client or Invalid client credentialsUnknown client id in this realm, or a wrong secret.
Client not allowed for direct access grantsA password grant for a client with Direct access grants off.
Client not enabled to retrieve service accountA client credentials grant for a client with Service accounts roles off.
Missing parameter: code_challenge_methodThe client requires PKCE and the request had none.
Account is not fully set upThe user has a required action pending, which a password grant cannot complete.

Errors by app type

Single-page and mobile apps

Expect invalid_grant when a code is redeemed twice, for example when a page reloads on the callback, or when the stored PKCE verifier was lost. Clear the code from the address bar once you have used it.

Back ends

Expect invalid_client after a secret rotation, and invalid_grant on refresh when sessions time out. Handle the second by sending the user to sign in again.

Services and devices

Client credentials calls fail with unauthorized_client when service accounts are off. Device flow clients must handle the four polling codes without treating authorization_pending as a failure.

Debugging an OAuth error step by step

  1. Note which endpoint returned the error: authorization, token, UserInfo or your API.
  2. Read both error and error_description.
  3. Compare the request with what the server expects. Our request builders show the exact parameters each flow needs.
  4. Check the server’s logs for the request time. Keycloak records failed logins and token requests as error events with a reason. Turn on saving user events in the realm to see them in the admin console.
  5. Start the flow again with fresh values once the cause is fixed.

Security notes

Show users a friendly message, not the raw error description. Descriptions can reveal details about your setup.

Never retry a code exchange with a different redirect_uri or verifier to make an error go away. Those checks are the protection. RFC 9700 relies on them to stop stolen or injected codes.

Treat an error redirect like any other: check state before acting on it, so an attacker cannot push fake errors into a user’s session.

Best practices

  • Branch on the error code in your program, not on the description text, which can change between versions.
  • Log the code, description and endpoint, but never tokens, codes or secrets.
  • Handle invalid_grant on refresh by signing the user in again.
  • For device flow polling, honor interval and slow_down.
  • Keep client secrets in one place, so a rotation does not leave a stale copy behind.
Questions

Frequently asked questions

What does use_dpop_nonce mean?

The server requires a nonce in DPoP proofs. Take the value of the DPoP-Nonce header from its response, put it in a new proof and send the request again.

What does invalid_grant mean in OAuth?

The authorization code, refresh token or other grant is invalid, expired, revoked, already used, or was issued to another client. In the code flow it also appears when redirect_uri or the PKCE verifier does not match.

What is the difference between invalid_client and unauthorized_client?

invalid_client means the client could not be authenticated. unauthorized_client means it was, but it may not use this grant or response type.

Why does Keycloak return Code not valid?

The code was already used, has expired, or belongs to another client. Codes are single-use and short-lived. A page reload on the callback often redeems the same code twice.

What does login_required mean?

A silent request with prompt=none found no session at the server. Send the user through a normal sign-in.

What does invalid_token mean on an API call?

The access token is expired, revoked, malformed, or from another issuer. Get a new token, for example with a refresh, and check the token’s issuer and audience.

What should a device do on authorization_pending?

Wait for the interval from the device authorization response and poll again. It is not a failure; the user has not finished yet.

Why do I get unsupported_grant_type?

The grant_type value is misspelled, the body was sent as JSON instead of a form, or the server does not offer that grant.

Why does Keycloak show an error page instead of redirecting with an error?

When the redirect URI or client id cannot be trusted, the server must not redirect. Keycloak shows the error, such as Invalid parameter: redirect_uri, on its own page.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.