← All articles

Access Token Expiration: What Expires and How to Check It

Two blank cards above a closed dark notebook with an amber bookmark.
Record validity information separately from the plan for obtaining a replacement.

Key takeaways

  • Access token expiration is a passive check against the exp claim, not a revocation; the client recovers by presenting its refresh token for a new access token.
  • Access, ID, and refresh tokens expire on different clocks: access tokens in minutes to an hour, refresh tokens in days to months, with expiry stored in different places for each.
  • You can check token expiration by decoding the JWT exp claim, reading headers like GitHub's X-GitHub-Expiration, or calling the provider's API for opaque credentials.
  • Auth0 defaults to 24-hour access tokens and 10-hour ID tokens, both editable in the dashboard or scriptable via the Management API.
  • APNs provider tokens expire after one hour with no revocation list, so they need per-app lifecycle tracking with a named owner and rotation deadline.

Access token expiration is the window, set at issuance, during which a token authorizes API calls; once it passes, the server rejects requests and your app must use its refresh token to get a new one. Access, ID, and refresh tokens expire on different clocks with different consequences, and each type hides its expiry in a different place. Below is a side-by-side comparison, Auth0's defaults, APNs quirks, and copy-paste commands for checking each one.

What happens when an access token expires?

Nothing dramatic. The token simply stops being accepted. Your app sends a request with the expired access token, and the API's authorization server rejects it, typically returning a 401 with an invalid_token error in the WWW-Authenticate header. That rejection is the whole event: expiration is a check the resource server performs against the token's exp claim, not an action anyone takes on the token itself.

The token is not revoked, deleted, or cleaned up. It still exists, still decodes, and still shows its old claims if you inspect it. RFC 6749 defines the expected recovery path: the client uses its refresh token to obtain a new access token. Expiry is a validity window, not a lifecycle event, which is why nothing in your vault or Secrets Manager notices it happened.

What is the difference between access token, ID token, and refresh token expiration?

Access tokens authorize API calls, ID tokens prove who the user is, and refresh tokens get you new access tokens without re-login. They expire on different clocks, store their expiry in different places, and expiry means something different for each.

Access tokenID tokenRefresh token
PurposeAuthorize API requestsAssert user identity to your appMint new access tokens
Typical lifetimeMinutes to an hourSimilar to access token, often minutesDays to months
Expiry stored inexp claim (JWT) or server-side introspectionexp claim in the JWTexp claim, or opaque token with server-side expiry
What expiry meansAPI rejects the call; client retries with a refreshApp should reject the assertion; identity claims are staleUser must re-authenticate; session ends

Access token expiration

When an access token expires, the resource server returns 401 and your client uses the refresh token to get a new one. Expiry is read from the exp claim for JWTs, or via introspection for opaque tokens. Short lifetimes limit blast radius if a token leaks.

ID token expiration

An expired ID token means the identity assertion is no longer trustworthy, not that the session is dead. Validate exp on every receipt and never use an ID token as an access credential.

Refresh token expiration

Refresh token expiry is your session ceiling. Long lifetimes trade UX for risk; rotation on each use shortens the window a stolen token stays useful. The same ownership-and-deadline discipline applies to non-OAuth credentials, as these API key expiration policy examples show (https://keyguardrail.com/blog/api-key-expiration-policy-examples).

How do you check token expiration in practice?

Three methods cover most cases: decode the JWT, read HTTP headers, or call the provider's API. Which one applies depends on whether the token is a JWT you can read or an opaque string only the issuer understands.

Decode the JWT exp claim

Every JWT carries an exp claim: a Unix timestamp, in seconds, after which the token is invalid. The OpenID Connect Core spec defines exp as the expiration time on or after which the ID token must not be accepted, and the same claim format applies to OAuth access tokens issued as JWTs. Paste the token into jwt.io to see the claims in a browser, or decode it from the command line without any third-party site:

echo 'eyJhbGciOi...' | cut -d. -f2 | base64 -d 2>/dev/null | jq .exp

Convert the result with date -d @1735689600 to get a human-readable time. One caution: the payload is base64url encoded, not standard base64, and the signature section is not needed to read the claims. Decoding is not verification, so only trust a decoded exp after checking the signature if the token's validity matters for a decision.

Check expiry without decoding (headers and API calls)

Some providers return expiration metadata in HTTP response headers or token endpoint responses. OAuth token responses include an expires_in field (seconds until expiry) alongside the access token, so capture it when the token is issued and store it next to the token. GitHub's API returns an X-GitHub-Expiration header on requests made with fine-grained tokens, which lets you compute expiry from any authenticated response without decoding anything. Stripe's Dashboard shows key creation dates, and its API error responses tell you when a key is no longer valid, though not when it will expire.

Checking expiry for opaque tokens

Opaque tokens, like many Stripe API keys or GitHub PATs, carry no readable exp claim at all. Your options narrow to three: query the provider's API for the credential's metadata, rely on the expiry date recorded when the credential was created, or probe the credential and treat a failure as the expiry signal. The last option is the worst, because it discovers expiration only after something breaks.

This is where a lifecycle layer earns its keep. If you track the issuance date and rotation policy (your 30/60/90 day rule) in one place, you never need to decode a token to answer "when does this die?" KeyGuardRail monitors credential lifecycle metadata without taking custody of the secret value, so you get expiry deadlines and ownership per key across AWS Secrets Manager, Stripe, and GitHub. For the reasoning behind metadata-only tracking, see our brief on automation access. The alternative, scattered spreadsheets and tribal knowledge, is exactly the "humans as the transport layer" problem you are trying to eliminate.

What are Auth0's default access and ID token expiration settings and how do you change them?

Default lifetimes

Auth0 issues access tokens with a default lifetime of 24 hours (86,400 seconds) and ID tokens with a default of 36,000 seconds (10 hours). Refresh tokens, when enabled, are long-lived and governed by separate rotation and reuse-interval settings.

Changing the settings

In the dashboard, go to Applications > [your app] > Settings and edit the Token Expiration (Seconds) field for access tokens; ID token lifetime is set under Applications > API settings or via the id_token_lifetime parameter. The Management API exposes the same fields, so you can script changes across environments instead of clicking through each app.

Choosing values

Shorter access token expiration (15-60 minutes) limits the blast radius of a leaked token, but pushes more refresh traffic and more mid-request 401s. Longer lifetimes reduce load and mobile re-auth prompts at the cost of a wider window for replay. Whatever you pick, record the value and the owner next to the credential. If you also hold long-lived API keys outside Auth0, tracking their expiry in one place (https://keyguardrail.com/blog/how-to-track-api-key-expiry) keeps the two lifetimes from drifting apart.

How does APNs token expiration differ from web/OAuth token expiration?

APNs provider tokens flip the usual OAuth model. Instead of a short-lived access token plus a refresh token, Apple has you sign a JSON Web Token with your key, and each token is valid for one hour from its timestamp. Your provider generates a new token whenever the old one nears that hour mark and caches it in memory; Apple documents this flow in its user notifications developer documentation.

There is no server-side revocation list to check. If your signing key leaks, you revoke it in your Apple developer account and every token signed with it stops working, rather than expiring individually. That is the opposite of OAuth expiry, where access token expiration is the primary containment mechanism and revocation is secondary.

Operationally this means tracking "expires in 60 minutes" per provider token, per app, across environments. That one-hour cycle is why APNs credentials belong on the same lifecycle inventory as your Secrets Manager entries and GitHub PATs, with a named owner and a rotation deadline (https://keyguardrail.com/brief/integration-credentials-october-2026).

How should refresh token expiration be configured to balance security and UX?

Refresh tokens are the long-lived part of your token pair, so their expiration policy carries most of your risk. The default tradeoff: short lifetimes cut the blast radius of a stolen token, long lifetimes reduce login friction and support load.

Rotation and reuse detection

Issue a new refresh token on every use and invalidate the old one. If a rotated token is presented twice, treat it as theft and kill the whole token family. This lets you run aggressive rotation without punishing legitimate users, because a mid-session refresh failure only happens when something is actually wrong.

Absolute vs sliding windows

An absolute window caps total lifetime regardless of activity. A sliding window extends on each use, so active users never re-authenticate. Absolute limits are non-negotiable for B2B apps, where an employee who left months ago should not still hold a valid session. A common pairing: 30-day absolute limit with 14-day sliding inactivity, rotating on every use.

For consumer apps, longer sliding windows are acceptable because the account value and blast radius are lower. For B2B, prefer shorter absolute caps aligned to your 30/60/90-day rotation policy, and let SSO handle the re-login. Whatever you pick, record the expiry and owner for each token so an expired session is a query, not an archaeology project.

What should your app do when a token expires mid-request?

Treat an expired access token as recoverable, not fatal. When an API call returns a 401, check whether the token's exp has passed, then retry once with a fresh token obtained via the refresh token. If the 401 came from a revoked or rotated refresh token, fail the request and force re-authentication instead of retrying in a loop.

Coordinate the refresh across concurrent requests. Without coordination, five in-flight calls that all hit a 401 will each trigger a refresh, and providers that rotate refresh tokens on use (Auth0 does this by default, per its refresh token documentation) will invalidate all but the first, cascading logouts. A single-flight guard, one promise or mutex per credential, collapses those calls into one refresh.

Build in clock-skew tolerance. Server and client clocks drift, so treat a token as expired a few seconds before its stated exp and accept a freshly issued token whose iat looks slightly ahead. Skewing early is cheap; a rejected token mid-retry is not.

How do you track token and credential expiration across providers without reading every token?

Access token expiration is the easy half. JWTs carry an exp claim your middleware can check, and refresh tokens have lifetimes your IdP controls. The harder half is everything else in your stack: Stripe API keys, GitHub PATs, and long-lived AWS access keys have no exp claim at all. They expire only when you decide they do, which usually means nobody decides.

That is where credential sprawl starts. A vault like AWS Secrets Manager, HashiCorp Vault, or Infisical stores and distributes secret values, but it does not answer "who owns this key, when was it created, and when is the 30/60/90 day rotation deadline?" Those questions live in spreadsheets and tribal knowledge, and they surface during audits or after an ex-employee's key shows up in a Postman collection. KeyGuardRail fills that gap as a lifecycle layer: it tracks ownership, creation dates, and rotation deadlines for credentials across AWS, Stripe, and GitHub without ever holding the secret values themselves. Your vault stays the system of record for secrets; KeyGuardRail stays the system of record for what expires, who owns it, and what happens next. You get the metadata-only audit trail without adding another custodian of secret values.

FAQ

Can an expired JWT still be valid if the signature checks out?

No. A valid signature proves the token was issued by your server and was not tampered with, but it says nothing about the exp claim. The resource server must check both: signature first, then expiry. A signed token past its exp is rejected, typically with a 401 and an invalid_token error in the WWW-Authenticate header.

Do access tokens get revoked when they expire?

No. Expiration is a passive check against the exp claim, not an action taken on the token. The token still exists, still decodes, and still shows its old claims if you inspect it. The resource server simply stops accepting it. Recovery follows the standard OAuth path defined in RFC 6749: the client presents its refresh token to obtain a new access token.

What is the default access token lifetime in Auth0 machine-to-machine apps?

Auth0's default access token lifetime is 24 hours (86,400 seconds), which applies to machine-to-machine applications as well. You can change it in the dashboard under Applications > [your app] > Settings via the Token Expiration (Seconds) field, or script it through the Management API. For M2M, shorter values such as 15-60 minutes reduce the blast radius of a leaked token.

How long should a refresh token last for a mobile app?

Consumer mobile apps can tolerate longer sliding windows because blast radius is lower, for example a 30-day absolute limit paired with 14-day sliding inactivity, rotating on every use. Rotation with reuse detection lets you run aggressive lifetimes without punishing legitimate users, since a mid-session refresh failure only happens when something is actually wrong. Whatever you choose, record the expiry and owner next to the credential.

Is there a way to get notified before a token or API key expires?

For JWTs, your middleware can read the exp claim and alert ahead of time. Opaque credentials like Stripe API keys and GitHub PATs carry no readable expiry, so you need a lifecycle layer that tracks creation dates and rotation deadlines. KeyGuardRail monitors that metadata across AWS, Stripe, and GitHub without holding the secret values themselves.