Skip to content

Token introspection request builder

Build a token introspection request (RFC 7662) that asks Keycloak whether a token is active, with client authentication.

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 check. A placeholder is filled in; yours stays in your browser.

Helps the server look the token up faster.

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

Introspection request

curl command
curl 'https://auth.example.com/realms/acme/protocol/openid-connect/token/introspect' \
  -H 'Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs' \
  --data-urlencode 'token=SAMPLE_ACCESS_TOKEN' \
  --data-urlencode 'token_type_hint=access_token'
Sample response for an active token (made-up values)
{
  "active": true,
  "client_id": "web-app",
  "username": "alice",
  "scope": "openid profile email",
  "sub": "1f8f4b3a-sample",
  "aud": "account",
  "iss": "https://auth.example.com/realms/acme",
  "exp": 1900000300,
  "iat": 1900000000,
  "token_type": "Bearer"
}
Inactive tokens
For an expired, revoked, unknown or malformed token the answer is only {"active": false}, with no reason (RFC 7662 section 2.2). Check active before any other field.
Call introspection from your back end with a confidential client’s credentials, such as the API’s own client. Never from a browser or mobile app.

How to use it

  1. Enter your Keycloak server URL and realm, or a custom introspection endpoint.
  2. Paste the token and, if you know it, its type.
  3. Enter the credentials of a confidential client, such as your API’s.
  4. Copy the request and check active in the response.

What to know

Introspection lets an API ask the server about a token instead of validating it locally. In Keycloak the endpoint is https://<host>/realms/<realm>/protocol/openid-connect/token/introspect.

The answer is JSON with active and, for an active token, claims such as sub, scope, client_id and exp. For an expired, revoked or unknown token it is only active: false, with no reason.

It adds a network call per check, so many APIs validate JWT access tokens locally and use introspection when they must know about revocation.

What token introspection is

Token introspection lets a protected resource ask the authorization server one question: is this token still good, and what does it mean? The answer comes back as JSON. The protocol is defined in RFC 7662, OAuth 2.0 Token Introspection.

It exists because some tokens cannot be checked locally. An opaque access token is just a random string; only the server that issued it knows what it stands for. A JWT access token can be validated with the issuer’s public key, but a signature check alone cannot tell you that the token was revoked or that the user’s session ended a minute ago. Introspection asks the source of truth.

The caller is usually an API, called a resource server in OAuth terms. A client app rarely needs introspection, because it should treat its own access token as opaque and simply use it.

How an introspection request works

The resource server sends a POST to the introspection endpoint with the token in a form-encoded body. It authenticates itself while doing so, because the answer reveals details about a token and its user. RFC 7662 leaves the exact authentication method to the server; client credentials are the common choice.

The request

Sample request (made-up host, client and token)
POST /realms/acme/protocol/openid-connect/token/introspect HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs

token=SAMPLE_ACCESS_TOKEN&token_type_hint=access_token

Only token is required. token_type_hint is optional and may be access_token or refresh_token. It only helps the server look the token up faster; a server that cannot find the token with the hint must still search other types.

The response

Sample response for an active token (made-up values)
{
  "active": true,
  "client_id": "web-app",
  "username": "alice",
  "scope": "openid profile email",
  "sub": "1f8f4b3a-sample",
  "exp": 1900000300,
  "iat": 1900000000,
  "token_type": "Bearer"
}

The only required field is active. For an active token the server usually adds fields such as scope, client_id, username, sub, aud, iss, exp and iat. For a token that is expired, revoked, unknown, malformed or issued to someone else, the answer is just {"active": false}. RFC 7662 section 2.2 says the server should not explain why, so the caller learns nothing it could abuse.

What this tool does

The tool builds the introspection request for you and shows it two ways: as a curl command you can paste into a terminal, and as the raw HTTP request. Nothing is sent. Every value stays in your browser.

  • It builds Keycloak’s endpoint from a server URL and realm name, or takes any custom introspection URL.
  • It adds the token and an optional token_type_hint.
  • It applies client authentication: client_secret_basic (an Authorization header), client_secret_post (secret in the body), or a signed JWT assertion you paste in for private_key_jwt or client_secret_jwt.
  • It shows a made-up sample of an active response, so you know what to expect.

It does not call the server, check a signature or decode the token. To read the claims inside a JWT, use the JWT decoder. To read a response you already have, use the token introspection viewer.

How to use the tool

  1. Choose Keycloak realm and enter your server URL and realm, or switch to Custom URL and paste the introspection endpoint from your discovery document.
  2. Paste the token you want to check. A placeholder is filled in so the page works on first load.
  3. Pick a token_type_hint if you know the type, or leave it unset.
  4. Choose how the calling client authenticates and enter its client id and secret, or paste a signed client assertion.
  5. Copy the curl command, or switch to the HTTP view to see the exact headers and body.
  6. Run the request from a machine you trust and check active before reading anything else.

Introspection in Keycloak

In Keycloak each realm has its own introspection endpoint at https://<host>/realms/<realm>/protocol/openid-connect/token/introspect. The discovery document at /realms/<realm>/.well-known/openid-configuration lists it as introspection_endpoint. You can read that document with the OIDC discovery viewer.

Call it with the credentials of a confidential client, one with Client authentication turned on. A common setup is a dedicated client for each API, used only for introspection.

A token from another realm is answered with active: false, because each realm is its own issuer with its own keys and sessions.

When to use introspection

Introspection costs a network call per check, so use it where it pays off.

APIs that must notice revocation quickly

An API that moves money, changes permissions or deletes data may want to know at once when a user signs out or an admin ends a session. Local JWT validation keeps accepting a token until exp. Introspection reflects the server’s current state.

Gateways and reverse proxies

An API gateway can introspect incoming tokens once and pass trusted claims to the services behind it. Cache the result for a short time, well under the token lifetime, to keep the load reasonable.

Debugging a token

When an API rejects a token and you do not know why, introspection tells you whether the server still considers it active. If it says active: false, the problem is the token or the session, not your API code.

When not to use it

Single-page apps, mobile apps and command-line tools should not introspect. They cannot keep the credentials introspection requires, and they should not depend on the content of an access token at all. If such an app needs user details, it should read the ID token or call the UserInfo endpoint.

Introspection or local JWT validation

IntrospectionLocal JWT validation
Network callOne per check (or per cache miss)None after the keys are fetched
Sees revocation and logoutYesNo, only exp
Works with opaque tokensYesNo
Needs client credentialsYesNo, only the public keys

Many teams combine the two: validate the JWT locally on every request, and introspect only for sensitive operations. To validate locally, fetch the realm’s keys from its JWKS endpoint and check the signature, iss, aud and exp. The JWT verifier shows how those checks fit together.

Common errors and how to fix them

Always active: false

  • The token expired. Check exp with the JWT decoder.
  • The token comes from another realm or another server. Compare its iss with the endpoint you call.
  • You sent Bearer in front of the token. Send the token alone.
  • The user’s session ended, or the token was revoked.

401 with invalid_client

The client credentials are wrong, or the client id is unknown in this realm. Call with a confidential client and check its secret. If the secret has special characters, see the client authentication header tool for how it must be encoded.

unsupported_grant_type or a 404

You probably posted to the token endpoint instead of the introspection endpoint, or left out /introspect at the end of the path.

Security notes

  • Call introspection only over https, and only from back-end code.
  • Give the introspecting client the least it needs, and use it for nothing else.
  • Do not log full tokens or full introspection responses. They identify users and can be replayed until they expire.
  • Check active first. A field such as scope means nothing when the token is not active.
  • Check the audience. An active token issued for another API is still not meant for yours. RFC 9700, the OAuth security best current practice, recommends restricting access tokens to the resource they are meant for.

Best practices

  • Cache positive answers briefly, keyed by a hash of the token, and never past the token’s exp.
  • Keep negative answers out of a long cache, and never record a network failure as active: false.
  • Treat a failed call as a failure, not as an inactive token. Return 503 rather than 401 if the server cannot be reached.
  • Send token_type_hint when you know the type; it saves the server a lookup.
  • Keep the introspection client separate from clients that users sign in through.

If you would rather not run the server side of this yourself, RealmDeploy runs upstream Keycloak for you on a dedicated cluster. The plans are on pricing.

Questions

Frequently asked questions

What is OAuth token introspection?

It is a request an API sends to the authorization server to ask whether a token is active and what it allows. It is defined in RFC 7662. The answer is JSON with an `active` field and, for active tokens, claims such as `sub`, `scope` and `exp`.

What is the Keycloak introspection endpoint URL?

`https://<host>/realms/<realm>/protocol/openid-connect/token/introspect`. Each realm has its own. The discovery document lists it as `introspection_endpoint`.

Why does Keycloak introspection return active: false?

The token expired, comes from another realm, was revoked, or its session ended. Also check that you sent the token itself, without the word Bearer. The server does not say which reason applies.

Can a public client call the introspection endpoint?

Call it from your back end with a confidential client’s credentials. Browser and mobile apps cannot keep a secret, and they should not inspect access tokens anyway.

Should I introspect every request?

Usually not. Validating a JWT locally is faster and needs no network call. Introspect when you must notice revocation quickly, when tokens are opaque, or for sensitive operations, and cache results briefly.

Can I introspect a refresh token?

RFC 7662 allows any token type the server issued, and `token_type_hint=refresh_token` tells the server what to look for. In practice only the client that holds a refresh token should ever see it, so introspecting one is mostly a debugging step.

What is the difference between introspection and the UserInfo endpoint?

Introspection is called by an API with its own credentials, to learn about a token. UserInfo is called with the access token itself, to read claims about the signed-in user. They answer different questions.

Is it safe to paste a token into this tool?

The tool builds the request in your browser and sends nothing. A live token still works until it expires, so prefer test tokens, and run the generated command 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.