Skip to content
Workforce IdentityMarkdown

Set how long tokens live

Choose how long access tokens, ID tokens, codes and assertions stay valid in a realm, and what each choice trades.

API

Every token and one-time value the realm hands out has a lifetime. Shorter means a stolen or revoked one is useful for less time; longer means fewer trips to the realm. The access token’s lifetime matters most: it’s how long an API that only checks signatures keeps accepting a revoked token. This guide is for realm administrators balancing the two.

Before you start:

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read the settings but not change them.
  • Where: today this is done through the API; Call the API shows how to get $CVYUH_SESSION.
SettingDefaultAllowedWhat it bounds
accessTokenLifetimeSecs300 (5 min)1 to 86400How long an API that only checks signatures keeps accepting a revoked token
idTokenLifetimeSecs3001 to 3600How long an ID token is valid. Apps read it once, at sign-in
authorizationCodeLifetimeSecs601 to 600How long a code waits for the app to redeem it
clientAssertionMaxLifetimeSecs3001 to 3600The furthest ahead a client’s signed assertion may expire
bootstrapAssertionLifetimeSecs3001 to 3600How long an agent’s one-time bootstrap assertion stays usable
clockSkewSecs600 to 300How far apart clocks may be when assertions are checked

Refresh tokens, device codes, approvals, pushed requests and logout tokens have lifetimes of their own: Keep apps signed in, Sign in a TV or command-line tool, Have an agent ask its owner.

  1. Send the lifetimes you want to change:

    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": 600, "authorizationCodeLifetimeSecs": 60 }'
  2. A value outside the allowed range is refused when you save it. The change applies to tokens issued after it; tokens already out keep the lifetime they were issued with.

  • Lifetimes are realm-wide. Per-client lifetimes aren’t offered.
  • Risky agents can be held shorter still, per risk class: see Agent guardrails.
  • FAPI 2.0 is stricter. A client held to FAPI 2.0 (see Hold a client to FAPI 2.0) has codes that live a minute at most, and its clock tolerance is a minute at most, whatever the realm says.

Each token answer’s expires_in, and each token’s exp, reflect the new lifetime. The change is in the realm’s change history, as a PATCHED record on oauth2Settings with the values before and after: see Audit → Config in the dashboard, or Change history.

SymptomCauseFix
The change is refusedA value is outside its allowed rangeUse a value from the table
Tokens still show the old lifetimeThey were issued before the changeWait for them to expire; new ones follow the change
A FAPI 2.0 client’s codes still last a minuteThe profile caps themExpected

Send the defaults from the table above.