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).RealmViewercan read the settings but not change them. - Where: today this is done through the API; Call the API shows how to get
$CVYUH_SESSION.
The lifetimes
Section titled “The lifetimes”| Setting | Default | Allowed | What it bounds |
|---|---|---|---|
accessTokenLifetimeSecs | 300 (5 min) | 1 to 86400 | How long an API that only checks signatures keeps accepting a revoked token |
idTokenLifetimeSecs | 300 | 1 to 3600 | How long an ID token is valid. Apps read it once, at sign-in |
authorizationCodeLifetimeSecs | 60 | 1 to 600 | How long a code waits for the app to redeem it |
clientAssertionMaxLifetimeSecs | 300 | 1 to 3600 | The furthest ahead a client’s signed assertion may expire |
bootstrapAssertionLifetimeSecs | 300 | 1 to 3600 | How long an agent’s one-time bootstrap assertion stays usable |
clockSkewSecs | 60 | 0 to 300 | How 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.
Change them
Section titled “Change them”-
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 }' -
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.
Good to know
Section titled “Good to know”- 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.
Check it worked
Section titled “Check it worked”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.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| The change is refused | A value is outside its allowed range | Use a value from the table |
| Tokens still show the old lifetime | They were issued before the change | Wait for them to expire; new ones follow the change |
| A FAPI 2.0 client’s codes still last a minute | The profile caps them | Expected |
Undo it
Section titled “Undo it”Send the defaults from the table above.
Related
Section titled “Related”- How fast revocation takes effect: where the access-token lifetime matters.
- Client credentials: the tokens a service gets for itself.
- Refresh tokens: how long an app stays signed in.