Skip to content

Token revocation request builder

Build a token revocation request (RFC 7009) that revokes an access or refresh token, as curl or raw HTTP.

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

Request

The base URL, without /realms/…. Add a path if your server has one, such as /auth on old versions.

The token to revoke. A placeholder is filled in; yours stays in your browser.

A sample value is filled in. Whatever you type stays in this page.

Revocation request

curl command
curl 'https://auth.example.com/realms/acme/protocol/openid-connect/revoke' \
  -H 'Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs' \
  --data-urlencode 'token=SAMPLE_REFRESH_TOKEN' \
  --data-urlencode 'token_type_hint=refresh_token'
A 200 does not prove the token existed
The server answers 200 for a token it revoked and also for one that was already invalid (RFC 7009 section 2.2). Only a client error such as invalid_client means it did not work.
Revoke the refresh token
Revoking a refresh token stops new access tokens from being issued with it. Access tokens already issued may keep working until they expire, unless the API checks with introspection.
The token must have been issued to the client that revokes it. Public clients send their client_id; confidential clients authenticate.

How to use it

  1. Enter your Keycloak server URL and realm, or a custom revocation endpoint.
  2. Paste the token and set token_type_hint.
  3. Authenticate as the client the token was issued to.
  4. Copy the request.

What to know

Revocation tells the server a token is no longer needed, for example when a user signs out of your app. In Keycloak the endpoint is https://<host>/realms/<realm>/protocol/openid-connect/revoke.

The server answers 200 whether or not the token was valid, so a 200 is not proof the token existed.

Revoke the refresh token to stop new access tokens. Access tokens already issued may keep working until they expire, unless the API checks them with introspection.

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.

Sample request (made-up host, client and token)
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_token
Response
HTTP/1.1 200 OK

There 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 token and an optional token_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

  1. Enter your Keycloak server URL and realm, or switch to Custom URL and paste the revocation_endpoint from your discovery document.
  2. Paste the token to revoke. A placeholder is filled in so the page works on first load.
  3. Set token_type_hint to refresh_token or access_token, or leave it unset.
  4. Choose the same client authentication your app uses at the token endpoint, and enter the client id and secret if it has one.
  5. 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.

Questions

Frequently asked questions

What is the Keycloak token revocation endpoint?

`https://<host>/realms/<realm>/protocol/openid-connect/revoke`. It is listed as `revocation_endpoint` in the realm’s discovery document. Send a form-encoded POST with `token` and the client’s authentication.

Why does revocation return 200 for an invalid token?

RFC 7009 says so on purpose. The client wants the token to stop working, and an invalid token already does not work. It also avoids telling a caller which tokens exist.

Should I revoke the access token or the refresh token?

Revoke the refresh token. That stops new access tokens from being issued. Access tokens are short-lived, and many APIs validate them offline, so revoking one often changes little.

Does revoking a token log the user out of Keycloak?

No. It invalidates that token. The user’s session and single sign-on cookie remain until you send the browser to the logout endpoint.

Can a public client revoke its tokens?

Yes. RFC 7009 lets a public client identify itself with `client_id` instead of authenticating. The token must still belong to that client.

Why does my revoked access token still work at the API?

The API probably validates JWTs locally and only checks `exp`. It cannot see revocation without calling introspection. Short access token lifetimes keep this window small.

What does token_type_hint do?

It tells the server which kind of token you are sending, so it can look it up faster. It is optional, and a wrong hint does not make the request fail.

How do I revoke all tokens for one user?

The revocation endpoint handles one token per request, sent by the client that holds it. To cut off a user everywhere at once, an administrator can sign the user out of their sessions in the Keycloak admin console. Tokens tied to those sessions then stop refreshing.

Is it safe to paste a token here?

The request is built in your browser and nothing is sent to us. The generated command carries a live token, so run it only from a machine you trust.

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.