What token revocation is
Token revocation is how a client tells the authorization server that it no longer needs a token. The server then invalidates it, so nobody can use it again. The protocol is defined in RFC 7009, OAuth 2.0 Token Revocation.
Without revocation, a token stays valid until it expires. For an access token that may be minutes. For a refresh token it can be days, weeks, or longer for offline tokens. If the user signs out of your app and you simply forget the tokens, a copy that leaked somewhere keeps working. Revocation closes that gap.
It is the client’s own clean-up step. An app revokes the tokens it holds when the user signs out, unlinks an account or uninstalls an integration.
How a revocation request works
The client sends a POST to the revocation endpoint with the token in a form-encoded body. A confidential client authenticates the same way it does at the token endpoint. A public client identifies itself with client_id, as RFC 7009 section 2.1 allows.
POST /realms/acme/protocol/openid-connect/revoke HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs
token=SAMPLE_REFRESH_TOKEN&token_type_hint=refresh_tokenHTTP/1.1 200 OKThere is no body to read. RFC 7009 section 2.2 says the server answers 200 both when it revoked the token and when the token was already invalid or unknown. That is deliberate. The client’s goal is that the token no longer works, and that is true in both cases.
The token_type_hint parameter
token_type_hint is optional. Its standard values are access_token and refresh_token. It lets the server look in the right place first. If the hint is wrong, the server must still search the other types, so a wrong hint never causes a failure.
What happens to related tokens
RFC 7009 says that when a refresh token is revoked, the server should also invalidate the access tokens issued from the same grant, if it supports revoking access tokens. When an access token is revoked, the server may also revoke the related refresh token. Servers differ here, so do not rely on one revocation clearing everything.
What this tool does
The tool builds a revocation request and shows it as a curl command and as the raw HTTP request. It sends nothing. The token and the client secret stay in your browser.
- It builds Keycloak’s revocation endpoint from a server URL and realm, or accepts any custom URL.
- It sets
tokenand an optionaltoken_type_hint. - It applies the client authentication you choose: none for a public client,
client_secret_basic,client_secret_post, or a signed JWT assertion you paste in. - It explains what a 200 does and does not prove.
It does not run the request, decode the token or check whether it was active. To confirm that a token stopped working, introspect it afterwards with the introspection request builder.
How to use the tool
- Enter your Keycloak server URL and realm, or switch to Custom URL and paste the
revocation_endpointfrom your discovery document. - Paste the token to revoke. A placeholder is filled in so the page works on first load.
- Set
token_type_hinttorefresh_tokenoraccess_token, or leave it unset. - Choose the same client authentication your app uses at the token endpoint, and enter the client id and secret if it has one.
- Copy the curl command, or read the HTTP view to see exactly what goes over the wire.
Revocation in Keycloak
In Keycloak the revocation endpoint is https://<host>/realms/<realm>/protocol/openid-connect/revoke. The discovery document lists it as revocation_endpoint, which you can check with the OIDC discovery viewer.
As RFC 7009 requires, the server checks that the token was issued to the client that revokes it, so one client cannot revoke another client’s tokens. A confidential client authenticates with its credentials; a public client sends its client_id.
Revoking a token is not the same as logging the user out. The user’s session at Keycloak, and the single sign-on cookie in their browser, live on. To end the session too, send the browser to the end session endpoint, which the logout URL builder builds for you.
Use cases
Sign-out in a web app with a back end
When the user signs out, the server revokes the refresh token it stored, deletes its own session, and then redirects the browser to the logout endpoint. Revoking first means the stored refresh token is useless even if your session store leaks later.
Mobile and desktop apps
A native app keeps a refresh token in the platform’s secure storage. On sign-out it revokes the token as a public client, with its client_id, and then deletes it from storage. If the device is offline, delete the token locally and accept that it lives until it expires.
Command-line tools and devices
A CLI that signed in with the device flow can offer a logout command that revokes its refresh token. That way a laptop that is later lost does not carry a working credential.
Disconnecting an integration
When a user removes a connected app, the app should revoke the offline or refresh token it held. This is the polite and safe way to end a long-lived grant.
Common errors and how to fix them
invalid_client or a client mismatch
invalid_client (HTTP 401) means the client credentials are wrong. The server also refuses when the token was issued to a different client. Use the same client id and authentication method that obtained the token. If the secret contains special characters, check the encoding with the client authentication header tool.
400 unsupported_token_type
The server does not support revoking that type of token. RFC 7009 defines this error. Revoke the refresh token instead and let the access token expire.
200 but the token still works
- You revoked a refresh token, and an access token already issued from it is still within its lifetime.
- The API validates JWT access tokens locally, so it cannot see revocation until
exp. - The token you revoked was not the one you thought. A 200 is returned for unknown tokens too.
Security notes
- Send revocation requests only over https. The body carries a live token.
- Revoke before you delete. Once the token is gone from your storage you cannot revoke it any more.
- Keep access tokens short-lived, so a token you could not revoke expires soon. RFC 9700, the OAuth security best current practice, also asks that refresh tokens for public clients be sender-constrained or rotated.
- Do not log the request body. It contains the token you are trying to make harmless.
Best practices
- Revoke the refresh token on sign-out. That stops new access tokens, which is what matters most.
- Treat a 200 as “this token no longer works”, not as “this token existed”.
- Retry on 503. RFC 7009 lets the server answer 503 with a Retry-After header when it is busy.
- Combine revocation with a logout redirect when you also want to end the single sign-on session.
- For APIs that must react at once, use introspection or short access token lifetimes; revocation alone does not reach APIs that validate tokens offline.
Our docs describe how we run Keycloak for customers if you would rather not operate it yourself.