Skip to content
Workforce IdentityMarkdown

Introspection

An API asks the realm whether a token is still good right now, and what it says.

AvailableAPIRFC 7662, RFC 9701

Introspection lets an API ask the realm about a token and get the answer as it stands now, not as it was when the token was issued. A token revoked a second ago, or one whose user was disabled, reads inactive at once. If the token is active, the answer says who it is about, which client holds it, its scopes, its audience, when it expires and the key it is bound to.

Use it for an API that wants the realm’s answer on every request rather than checking signatures itself, and for a refresh token, which only the realm can read. Behind the gateway it isn’t needed: the gateway keeps its own revocation list.

  • Who can do it: your API calls introspection with its own client credentials. A realm administrator (a group holding RealmOwner) registers the API’s client and lists what it serves; RealmViewer can read it.
  • Where: today the client is set up through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: the API has a confidential client of its own, with servesResources naming its audience.

The API authenticates as its own client, as at the token endpoint, and posts the token to https://foobar.cvyuh.com/oauth2/introspect:

Terminal window
curl https://foobar.cvyuh.com/oauth2/introspect \
-d token=eyJhbGciOiJFUzI1NiIsInR5cCI6ImF0K2p3dCJ9… \
-d client_id=orders-api \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion=eyJ…

For an active access token, the answer is the token’s claims, with active and token_type added:

{
"active": true,
"iss": "https://foobar.cvyuh.com/oauth2",
"sub": "5b0e3c4a-8f1d-4e2b-9a6c-7d3f1e0b2c48",
"client_id": "orders-web",
"aud": "https://orders.example.com/api",
"scope": "orders.read",
"exp": <unix time>,
"cnf": { "jkt": "0ZcOCORZNYy-DWpqq30jZyJGHTN0d2HglBV3uiguA4I" },
"token_type": "DPoP"
}

token_type is DPoP for a token bound to a key (it carries cnf), else Bearer. For a refresh token, the answer is active, client_id, sub, scope, aud and exp, with cnf when the token is bound to a key and acr when the sign-in had one. Anything else, or a token this caller may not see, is answered {"active": false}.

A token is inactive when:

  • it has expired, or been revoked;
  • any token it was exchanged from (through token exchange) has been revoked;
  • its refresh family, session or client grant was revoked;
  • its user, client or any agent in it may no longer act;
  • a governed scope it holds (governed scopes) is no longer granted to whom it is about, or the realm’s issuance policy set no longer allows it.

Send Accept: application/token-introspection+jwt, and the answer comes as a JWT signed by the realm, of type token-introspection+jwt. It is signed with the client’s introspectionSignedResponseAlg, else ES256 for a fapi2 client, else the first of the realm’s keySettings.algorithm.oauth2.introspection (RS256 by default). Its claims are iss (the realm), aud (the caller’s client_id), iat, and token_introspection, which holds the answer above.

On the API’s own client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client; see Call the API), list the audiences it serves:

WhereSettingWhat it does
The API’s clientservesResourcesThe audiences this API is, so it may introspect their tokens. Empty by default
The API’s clientintrospectionSignedResponseAlgThe algorithm its signed answers use, one of the realm’s. A fapi2 client may name only ES256 or PS256
RealmclockSkewSecsThe clock tolerance a revocation is kept beyond a token’s expiry (default 60)
Realm, keySettingsalgorithm.oauth2.introspectionThe algorithms a signed answer may use (RS256 and ES256 by default); listed in the discovery document
Setting or limitDefaultRange
servesResourcesempty: the API learns only of its own tokensabsolute URIs
clockSkewSecs: how long past exp a revocation is kept600 to 300
introspectionSignedResponseAlgnone: plain JSONone of the realm’s algorithms (ES256, PS256 under fapi2)
SymptomCauseFix
Every token reads {"active": false}The API’s client doesn’t list the tokens’ audience in servesResourcesAdd the exact audience your API’s tokens carry
invalid_clientThe API calls without authenticating, or its client is publicAuthenticate as a confidential client
A refresh token reads inactive to your APIOnly the client it was issued to may see a refresh tokenIntrospect refresh tokens from the app that holds them

Introspection writes no record per call. Revocations it reflects are TOKEN_REVOKED records (Revoke tokens).

  • The caller authenticates first. A public client can’t introspect: it’s refused invalid_client.
  • Only two callers learn anything: the client the token was issued to, and an API whose client lists the token’s audience in servesResources. Anyone else gets {"active": false}, the same as for a token that doesn’t exist. A refresh token is shown only to the client it was issued to.
  • token_type_hint only orders the search. refresh_token looks among refresh tokens first, then access tokens. Any other hint, or none, looks the other way round. A wrong hint never makes a token inactive.
  • A revoked token is kept revoked until its exp plus the realm’s clock tolerance (clockSkewSecs), so it never reads active again while it could still verify.
  • Access and refresh tokens only. A transaction token answers {"active": false}.
ErrorWhen
invalid_clientThe caller doesn’t authenticate, or is a public client
invalid_requestNo token is sent, or a parameter is sent twice

A token that is unknown, expired, revoked or another’s is never an error: it’s {"active": false}.