Skip to content
Workforce IdentityMarkdown

Access tokens

Every token the realm issues for an API is a short-lived signed JWT that names its API, its caller and what it allows, so your API can check it on its own.

AvailableAPIRFC 9068, RFC 7519

Whatever grant an app, service or agent uses, what it gets for your API is the same kind of token: a JSON Web Token, signed with the realm’s key, that names the API it is for, who it is about, which client asked for it, and what it allows. Your API checks the signature against the realm’s published keys and reads the claims, with no call to the realm on each request.

Read this page when you build or configure an API that accepts the realm’s tokens, or when you decide how long tokens should live. Access tokens are short by default, five minutes, because their lifetime bounds how long a revoked user, client or agent keeps access.

  • Who can do it: a realm administrator (a group holding RealmOwner) sets the lifetime; RealmViewer can read it. Your API needs no right: it reads the realm’s public keys.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: your API knows its own name, the resource clients ask for it by (Resource indicators).

The token’s header names its type, at+jwt, and is signed ES256 with the realm’s signing key. The claims, for a user who signed in to the wiki through the browser sign-in:

{
"iss": "https://foobar.cvyuh.com/oauth2",
"sub": "3f9b2c71-8d4e-4a6f-b1c2-7e5d9a0f3b48",
"aud": "https://wiki.example.com/api",
"exp": <iat + 300>,
"iat": <unix time>,
"jti": "0193a7c2-5d1e-7f00-9b3a-6c2d1e0f4a58",
"client_id": "team-wiki",
"principal_type": "user",
"scope": "openid profile wiki:read",
"sid": "6f1e2d3c-4b5a-4968-8776-a5b4c3d2e1f0"
}

Every token carries these:

ClaimWhat it says
issThe realm that issued it
subWho the token is about: a user’s ID, an agent’s ID, or the client’s own ID
audThe API it is for (Resource indicators)
exp, iatWhen it ends, and when it was issued
jtiThe token’s own ID
client_idThe client that asked for it
principal_typeWhat sub names: user, agent, or oauth2Client for a service acting as itself. An API never mistakes a client for a user

Some tokens carry more, depending on how they were issued:

ClaimWhen it’s there
scopeThe scopes granted, when any were
authorization_detailsThe rich authorization details granted, when any were
sidThe sign-in session the token ends with. Absent on a token that outlives the session (offline_access)
familyThe refresh token family it was issued under
actWho acts for sub, on a delegated token
cnfThe key the token is bound to: jkt for a DPoP key, x5t#S256 for a client certificate. A token without it is a bearer token
statusWhere an API checking offline reads whether it was revoked (Status lists)
mode, risk_class, autonomy_tier, business_ownerOn a token about an agent: what a policy decides on beside who it is

To check a token, your API:

  1. Reads the realm’s signing keys from jwks_uri in the discovery document (https://foobar.cvyuh.com/oauth2/jwks), and caches them.
  2. Checks the header’s typ is at+jwt and the signature verifies with the key the header’s kid names.
  3. Checks iss is the realm, aud names this API, and exp hasn’t passed.
  4. Decides on sub, principal_type, scope and the rest.

An API that needs to know a token was revoked before it ends can introspect it, or read the realm’s status list. The gateway does all of this for an API you put behind it.

There’s nothing to turn on: every grant issues these. The realm’s settings set how long they last (see Call the API):

Terminal window
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "accessTokenLifetimeSecs": 300 }'
WhereSettingWhat it does
RealmaccessTokenLifetimeSecsHow long access tokens live, from 1 to 86400 seconds (default 300)
Realm, keySettingsalgorithm.oauth2.accessTokenThe signing algorithm. ES256, the only one offered
Setting or limitDefaultRange
accessTokenLifetimeSecs300 (five minutes)1 to 86,400
Signing algorithmES256ES256 only
A token tied to a sessionends by the session’s endfixed
SymptomCauseFix
Your API refuses tokens after a key rotationIt cached the key set and doesn’t know the new kidFetch the key set again when a token names an unknown kid
Your API refuses a token as for another audienceThe client asked for another API, or none and its default is anotherHave the client send resource with your API’s name
Tokens end sooner than accessTokenLifetimeSecsThe session ends first, or the agent’s risk class caps itExpected; refresh, or check the agent’s guardrails
invalid_token with BearerThe token is DPoP-boundSend it as Authorization: DPoP <token>, with a proof

Each token is one TOKEN_ISSUED record, under the user or agent it is about, with its jti (tokenId), its client, the scopes and API granted, and the key it is bound to. Find one token by its jti on the principal’s trail (Read a user’s or agent’s trail). A change to the lifetime is in Audit → Config.

  • Only an asymmetric algorithm signs them. No shared-secret algorithm is offered, because every API that checks a token would then hold the key that makes them.
  • A token never outlives its session. A token tied to a session (sid) has its lifetime cut to the session’s end, and ends with it when the user signs out (Logout).
  • An agent’s token can be shorter. The realm’s agent guardrails cap its life by the agent’s risk class.
  • The token’s claims are for the API, not the app. An app learns who signed in from the ID token and userinfo, never by reading the access token.
  • The keys rotate. Fetch the key set again when a token names a kid you don’t hold (Signing keys).