Token expiration is the point in time after which a security token, such as an OAuth 2.0 access token, an ID token or a session cookie, is no longer accepted by the systems that rely on it. In identity & access management, the access token lifetime limits how long a credential remains useful, which caps the damage of a stolen token and forces periodic revalidation of the user and the granted permissions.
Expiration is one of the most important controls in Cybersecurity token design because bearer tokens grant access to whoever presents them. A short lifetime shrinks the window of misuse, while refresh mechanisms preserve a smooth user experience without asking for a password every few minutes.
How token expiration is enforced
Token expiration is enforced either by reading a timestamp inside the token or by checking a server-side record. Self-contained tokens such as JSON Web Tokens carry an exp claim, expressed as seconds since the Unix epoch, and every resource server compares it with its own clock before accepting the request.
Reference tokens, also called opaque tokens, contain no readable data. The resource server sends them to the authorization server through token introspection, defined in RFC 7662, and the response states whether the token is still active. This design allows immediate revocation but adds a network call to every validation.
The following table lists the JWT claims that govern a token’s time window and how validators use them.
| Claim | Meaning | Validator behavior |
|---|---|---|
exp | Expiration time | Reject the token at or after this moment |
nbf | Not before | Reject the token before this moment |
iat | Issued at | Used to compute age and enforce maximum lifetime |
auth_time | Time of user authentication | Triggers reauthentication when too old |
Because distributed servers rarely share a perfect clock, validators usually allow a clock skew tolerance of about 30 seconds to five minutes. A tolerance that is too generous quietly extends every token’s real lifetime.
Typical lifetimes for different token types
Different token types carry different lifetimes because they protect different assets and face different exposure. There is no universal standard value; the figures below reflect common practice and depend on risk tolerance, client type and regulatory context.
| Token type | Typical lifetime | Main reason |
|---|---|---|
| Access token | 5 to 60 minutes | Bearer credential sent with every request |
| ID token | 5 to 60 minutes | Proves a recent login to the client |
| Refresh token | Hours to 90 days | Stored securely and used rarely |
| Authorization code | Under 10 minutes | Single-use exchange step in OAuth 2.0 |
| Session cookie | Idle 15 to 30 minutes, absolute 8 to 24 hours | Balances security with convenience |
| SAML assertion | Usually under 5 minutes | Consumed once at login |
Sessions and refresh tokens typically combine an idle timeout, which ends the session after inactivity, with an absolute timeout, which ends it regardless of activity. The absolute limit guarantees that even an actively abused credential eventually stops working.
Expiration, revocation and refresh compared
Expiration, revocation and refresh are complementary mechanisms that together define when a token stops being valid. Expiration is passive and predictable, revocation is an active decision to end validity early, and refresh replaces an expiring token with a new one.
| Mechanism | Trigger | Strength | Weakness |
|---|---|---|---|
| Expiration | Fixed time passes | No server lookup for JWTs | Stolen token works until expiry |
| Revocation | Logout, compromise or policy change | Ends access immediately | Needs introspection or deny lists |
| Refresh | Access token near expiry | Keeps users signed in | Refresh token becomes a prime target |
| Credential rotation | Scheduled key or secret change | Invalidates all tokens signed with old keys | Disruptive if done abruptly |
Refresh token rotation strengthens the refresh model: each use returns a new refresh token and invalidates the old one. If an attacker replays a used refresh token, the authorization server detects the reuse and can revoke the entire token family, which is a recommended pattern for public clients such as single-page applications.
Choosing an appropriate token lifetime
Choosing a token lifetime means balancing exposure against cost: shorter tokens limit misuse, but they increase traffic to the identity provider and the frequency of refresh failures. The right value depends on the sensitivity of the resource, how tokens are stored, and whether revocation is available in real time.
| Scenario | Recommended approach | Reason |
|---|---|---|
| Banking or administrative APIs | Access tokens of 5 to 10 minutes | High impact of a stolen token |
| Internal microservices | Short JWTs with automated renewal | Avoids introspection latency |
| Mobile application | Short access tokens, rotating refresh tokens | Device loss is a realistic risk |
| Browser single-page application | Short tokens and backend-held refresh tokens | Browser storage is exposed to script |
| Long-running batch jobs | Client credentials with automatic re-request | Avoids long-lived static tokens |
Sensitive operations often require step-up authentication regardless of token age. A policy might demand that auth_time be no older than 15 minutes before allowing a payment, even when the access token itself is still valid.
Common mistakes with token expiration
Most failures related to token expiration come from implementation shortcuts rather than from the standards themselves. The following mistakes appear repeatedly in security reviews.
- Not validating `exp` at all, which turns every issued token into a permanent credential.
- Very long access token lifetimes, such as several days, chosen to avoid building a refresh flow.
- Non-expiring refresh tokens without rotation, idle limits or binding to a client.
- Assuming logout revokes JWTs: deleting a cookie does not invalidate a self-contained token already copied by an attacker.
- Ignoring clock drift, which causes sporadic rejections or silently extends validity.
Binding tokens to a client, for example through mutual TLS or DPoP proof-of-possession, reduces the value of a stolen token beyond what expiration alone can achieve, because the thief also needs the client’s private key.
In everyday language
A token is like a wristband at a festival. It proves you paid, so staff let you in without checking your ticket each time. Token expiration means the wristband is only valid for a set time, perhaps one day.
If someone steals your wristband, they can use it only until it expires. To stay inside longer, you show your ticket again and receive a fresh band. Short validity limits the harm of theft, while the quick renewal keeps the experience convenient.
Seen in the real world
An online retailer runs a single-page web store backed by an OAuth 2.0 authorization server. Originally, access tokens lasted 24 hours and were kept in browser storage. A security review shows that a cross-site scripting flaw could let an attacker copy a token and act as the customer for a full day.
The team reduces the access token lifetime to 10 minutes, moves refresh tokens to a backend component that holds them in a secure, HTTP-only cookie, and enables refresh token rotation with reuse detection. Checkout additionally requires a login within the last 15 minutes. Months later, a test token captured during a penetration exercise stops working after ten minutes, and its replayed refresh token revokes the whole session family, confirming that the new design limits real exposure.