Why token lifetimes matter
An access token works for anyone who holds it until it expires. Short lifetimes limit the damage of a leaked token; long lifetimes save round trips but widen that window. Most token problems in day-to-day work are timing problems: a token that expired a moment ago, one that is not valid yet on a server with a fast clock, or a lifetime nobody meant to set.
This tool reads the time claims in a token and lays them out on a timeline next to the current time, with a countdown that ticks every second.
The time claims in a JWT
| Claim | Name | What it means |
|---|---|---|
iat | Issued at | When this token was created |
nbf | Not before | The token must not be accepted before this time |
exp | Expiration | The token must not be accepted at or after this time |
auth_time | Authentication time | When the user last actively signed in (OpenID Connect) |
All four are NumericDate values: seconds since 1970-01-01 in UTC, ignoring leap seconds (RFC 7519). They carry no time zone. The tool shows each one in UTC and in your local time zone, with the raw number next to it.
"iat": 1764000000 → 2025-11-24T16:00:00Z
"exp": 1764000300 → 2025-11-24T16:05:00Z (5 minutes later)What the checker shows
- A status: valid now, not valid yet, expired, or no expiry at all.
- A timeline with a mark for each time claim and one for now.
- Each time in your local time, in UTC, as a relative time and as the raw number.
- The lifetime from
iattoexp, and the time left.
Everything is computed against your computer’s clock. If your clock is wrong, the status is wrong too, which is itself a useful hint when a server and a laptop disagree.
How to check a token
- Paste the token. The
Bearerprefix is fine. - Read the status line under the box.
- Look at the timeline: where “now” sits between the marks tells you the story at a glance.
- Read the lifetime and time left in the table.
Token lifetimes in Keycloak
Keycloak sets token lifetimes in the realm and lets clients override some of them.
| Setting | Where | Affects |
|---|---|---|
| Access Token Lifespan | Realm settings, Tokens; per client in Advanced | exp of access tokens (5 minutes by default) |
| SSO Session Idle | Realm settings, Sessions | How long a session lives without activity; caps refresh tokens |
| SSO Session Max | Realm settings, Sessions | The longest a session can live, however active |
| Offline Session Idle | Realm settings, Sessions | How long offline tokens stay usable without use |
A refresh token’s exp follows the session settings rather than the access token lifespan. That is why a refresh token usually lives much longer than the access tokens it produces.
iat and auth_time after a refresh
When an app refreshes, Keycloak issues a new access token with a new iat and exp. The auth_time claim stays the time the user actually signed in. Comparing the two tells you how long ago the user last entered credentials, which matters for sensitive actions.
Use cases
“Token expired” errors that seem too early
Paste the token that failed. If its lifetime is 5 minutes and your app cached it for longer, the fix is to refresh before exp, not to raise the lifespan.
“Token not yet valid” errors
If a fresh token shows as not valid yet, the issuer’s clock is ahead of the checker’s. Sync both with NTP, and allow a small clock skew in your validation.
Checking a configuration change
After changing a lifespan in the admin console, get a new token and confirm the lifetime here. Tokens issued before the change keep their old expiry.
Planning refresh timing
Apps should refresh a little before exp, not at the moment it passes. Seeing the real lifetime helps you choose how early.
Common mistakes
- Treating JWT times as milliseconds. A 13-digit value is milliseconds and will be read as a date far in the future.
- Comparing times in local time. NumericDate is UTC; convert only for display.
- Raising the access token lifespan to work around refresh bugs. Fix the refresh logic instead.
- Expecting a revoked token to show as expired. Revocation does not change
exp; only introspection or the session state reveals it.
Refreshing before expiry
A client that waits for a 401 before refreshing makes users see errors. A client that refreshes on a timer, slightly before exp, never does. The usual approach is to read exp from the access token response, or from the expires_in value next to it, and schedule the refresh a little earlier.
// expires_in comes with every token response, in seconds
const refreshAt = Date.now() + (tokenResponse.expires_in - 30) * 1000;
setTimeout(refresh, refreshAt - Date.now());The token response from Keycloak’s token endpoint includes expires_in for the access token and refresh_expires_in for the refresh token. They are relative seconds, so they do not depend on the client’s clock.
Clock skew, explained
Two machines rarely agree on the time to the second. If the issuer’s clock runs ahead of the API’s, a fresh token looks issued in the future; if it runs behind, tokens seem to expire early. Validators allow a small skew to absorb the difference.
| Situation | What you see | What to do |
|---|---|---|
| Issuer clock ahead | iat or nbf in the future | Sync clocks; allow 30 to 60 seconds of skew |
| Issuer clock behind | Tokens expire earlier than expected | Sync clocks |
| Your laptop clock wrong | This page shows odd relative times | Fix your computer’s time setting |
The expiry checker uses your computer’s clock with no skew, so it shows exactly where the token stands. The claims validator applies a configurable skew the way an API would.
Reading the timeline
The bar runs from the earliest time claim to the latest, with “now” placed among them. The blue part is the window in which the token is valid: from nbf, or iat if there is no nbf, to exp.
- “now” inside the blue window: the token is valid by time.
- “now” to the right of
exp: the token has expired. - “now” to the left of
nbf: the token is not valid yet. auth_timefar to the left: the user signed in long ago and the app has been refreshing since.
Security notes
A token that has not expired is not necessarily valid: its signature, issuer and audience still need checking, and its session may have ended. Use the signature verifier and the claims validator for the rest.
The sample token on this page is unsigned and made up. Its times are set when the page opens so the timeline has something live to show.
Tokens without exp never expire on their own. The security checker flags them.
Best practices
- Keep access tokens short-lived, minutes rather than hours.
- Refresh before expiry and handle a failed refresh by signing the user in again.
- Allow 30 to 60 seconds of clock skew in validation, and keep server clocks synced.
- Use
auth_timewhen an action needs a recent sign-in.