Join our Newsletter — 33% off our NHI Course
Home› Guides› Token Lifetime Policy Design Guide: Balancing Security and…
Guide Non-Human Identity (NHI)

Token Lifetime Policy Design Guide: Balancing Security and Reliability

PDF for newsletter subscribers · free to read online

← All guides
By Lalit Choda, NHI Mgmt Group Updated 24 October 2026 15 min read
On this page

Every token lifetime is a bet: too long and a stolen token stays useful for months, too short and pipelines, integrations and users break at the worst moment. Most organisations never make that bet deliberately. They inherit vendor defaults, add exceptions when something fails, and end up with refresh tokens that live for years beside access tokens that expire every hour. This guide sets out how to design a token lifetime policy on purpose: which lifetimes matter, what the standards and major platforms actually allow, how to tier lifetimes by risk, and how to roll out shorter lifetimes without outages. It is written for identity architects, platform engineers and NHI programme owners who set or review token settings for people, workloads and third-party integrations.

Key takeaways

  • The refresh token is the real lifetime. An access token that expires in an hour gives little protection if the refresh token behind it never expires, as the Gainsight tokens created between 2017 and 2023 showed.
  • Lifetime is one control among four. Expiry works with audience restriction, sender-constraining and revocation; short lifetimes compensate for weak revocation, not for broad scopes.
  • Tier by risk, not by application. Define a small set of lifetime tiers (privileged, standard, workload, integration) and map every token issuer to one, with documented exceptions.
  • Workloads should not hold long-lived tokens at all. Federation and platform-issued credentials (STS, GCP short-lived tokens, Kubernetes bound tokens, GitHub App installation tokens) make one-hour or shorter lifetimes practical.
  • Reliability is a design input. Renew early, cache tokens correctly and test expiry in staging, so shorter lifetimes do not become the outage that forces everyone back to long ones.

Which lifetimes a policy must cover

"Token lifetime" is several separate settings, often owned by different teams. A policy that only sets access token lifetime leaves most of the exposure untouched. Map each of these explicitly.

LifetimeWhat it boundsTypical control pointExposure if too long
Access token lifetimeHow long one token is accepted by an APIAuthorisation server or IdP policyReplay of a leaked token from logs, memory or proxies
Refresh token absolute lifetimeHow long a grant can keep minting access tokensAuthorisation server, SaaS connected-app settingsPersistent access long after the person or vendor relationship changed
Refresh token idle timeoutHow long an unused grant survivesAuthorisation serverForgotten integrations that still work when stolen
Web session overall and inactivity timeoutHow long a signed-in browser session lastsApplication and IdP session settings, Conditional AccessStolen session cookies replayed (ATT&CK T1539)
Workload credential lifetimeHow long a cloud or cluster credential is validSTS, cloud IAM, Kubernetes API serverExfiltrated credentials used from outside the environment
Personal access token and API key expiryHow long a static token worksSaaS and developer platform policyTokens leaked in code that still work years later
Signing key lifetimeHow long tokens signed by one key can be trustedIdP key rotation, JWKS publicationForged tokens if a key is stolen (T1606.002 for SAML)

The broader controls around stealing and replaying tokens, including JWT validation, are in the Token and Session Security Guide. This guide concentrates on the lifetime decisions themselves.

What the standards say

  • RFC 9700 (OAuth 2.0 Security Best Current Practice, January 2025): section 2.2.2 states that refresh tokens for public clients must be sender-constrained or use refresh token rotation. Section 2.3 says access tokens should be audience-restricted to a specific resource server, using the aud claim, the resource parameter (RFC 8707) and narrow scopes. Sections 2.2.1 and 4.10.1 recommend sender-constraining with mutual TLS (RFC 8705) or DPoP (RFC 9449), and note that this weakens if an attacker steals both the token and its key.
  • NIST SP 800-63B-4 reauthentication: sessions have an overall timeout and an inactivity timeout, and the session ends when either expires. At AAL2 the overall timeout should be no more than 24 hours and the inactivity timeout no more than 1 hour. At AAL3 the overall timeout shall be no more than 12 hours, with inactivity of no more than 15 minutes. At AAL1 the overall timeout should be no more than 30 days. The same section allows limits to be extended where device-bound session technology is used, which is the formal basis for trading binding against lifetime.
  • NIST SP 800-53 Rev. 5: AC-12 Session Termination, IA-11 Re-authentication, SC-23 Session Authenticity and IA-5 Authenticator Management are the controls an auditor will map a lifetime policy to.

None of these documents gives a single "correct" number for API access tokens. That is deliberate: the right value depends on what else protects the token.

Platform settings and their real limits

Policy must fit what platforms allow. These values are from vendor documentation; check them again before you write them into a standard, because defaults change.

PlatformSettingDocumented range or defaultDesign note
Microsoft Entra IDAccessTokenLifetime in a tokenLifetimePolicy (Microsoft Graph)10 minutes to 1 day; default access tokens are a random 60 to 90 minutes; ID and SAML2 tokens 1 hourApplies to access, ID and SAML2 tokens. An organisation-level policy overrides an application-level one
Microsoft Entra IDRefresh and session tokensNot configurable since 30 January 2021; default max inactive time 90 days, max age until revokedControl user sign-in frequency with Conditional Access instead. Managed identities do not support token lifetime policies
Microsoft Entra IDContinuous access evaluation (CAE)Access tokens may extend to 24 to 28 hours when client and resource support CAELonger lifetime is acceptable because revocation is near real time for events such as account disablement
AWS STSDurationSeconds on AssumeRole; role MaxSessionDuration900 to 43,200 seconds, default 3,600; role maximum 1 to 12 hours; role chaining capped at 1 hourRequests above the role maximum fail, so changing the role setting can break callers
Google Cloud IAMgenerateAccessToken lifetimeDefault maximum 1 hour, extendable to 12 hours only via the constraints/iam.allowServiceAccountCredentialLifetimeExtension organisation policy; OIDC ID tokens 1 hourTreat any service account on the extension list as an exception with an owner
Okta authorisation serversAccess policy rule: access and refresh token lifetimesSet per grant type, user and scope; rules evaluated in priority order, first match winsRule order matters: a broad rule above a strict one silently wins
GitHubApp installation access token; organisation PAT policyInstallation tokens expire after 1 hour and can be limited to up to 500 repositories and named permissions; fine-grained PATs default to a 366-day maximum, classic PATs have no expiry requirement by defaultOrganisation maximums block non-compliant tokens rather than revoking them, so expect rejected API calls on rollout
KubernetesProjected service account token expirationSecondsDefault 1 hour, minimum 10 minutes; the kubelet refreshes the token before expiryApplications must re-read the token file rather than caching it at start-up

Designing lifetime tiers

A workable policy has four or five tiers that every issuer maps to. The values below are a reasoned starting point, not a standard; adjust them to your platforms and record why.

TierExamplesAccess token or credentialRefresh or sessionRequired compensating controls
1. Privileged humanCloud console admins, IdP admins, PAM sessionsPlatform minimum, 10 to 60 minutesOverall 12 hours or less, inactivity 15 minutes (AAL3 values)Phishing-resistant MFA, managed device, re-authentication for sensitive actions
2. Standard workforceEmail, collaboration, internal appsPlatform default (around 1 hour), or longer only with CAEOverall up to 24 hours, inactivity 1 hour for AAL2 apps; longer on bound, managed devicesConditional Access, revocation on risk events
3. Workload, same platformPods, functions, VMs using platform identity1 hour or less, issued automaticallyNo refresh token: the platform reissuesAudience restriction, least-privilege role, no static fallback key
4. Workload, cross-platformCI/CD to cloud, cloud to cloud15 to 60 minutes via federationNone: re-federate per job or per hourTrust policy bound to repository, branch or workload subject
5. Third-party integrationSaaS connected apps, vendor OAuth clients, AI agents acting for usersPlatform default, 1 hour or lessAbsolute refresh lifetime of 90 days or less with idle timeout and rotation; re-consent on expiryIP restriction where the platform supports it, scope review, named business owner
  • Static tokens: personal access tokens and API keys that cannot be federated get an enforced maximum (for example 90 days for write access, never "no expiry") and an owner. See the Secrets Rotation Runbook Template.
  • Exceptions: every lifetime above a tier's ceiling needs a named owner, a reason, a compensating control and an end date. Review exceptions quarterly.
  • Agents: AI agents that call APIs on a user's behalf belong in tier 5 if a vendor runs them and tier 4 if you do. Delegated tokens should be shorter-lived than the user's own. See the OAuth Token Exchange and Delegation Guide.

Trade-offs and decision guidance

Short lifetime or fast revocation?

Short lifetimes cap exposure automatically but cost token traffic and resilience. Fast revocation lets tokens live longer but only works if every resource checks it. Choose short lifetimes for self-contained JWTs that resource servers validate locally, because they cannot be recalled. Choose longer lifetimes with revocation where the platform enforces it at the resource, as with Entra CAE or opaque tokens checked by introspection. Do not assume revocation works because the IdP offers a revoke button: test whether a revoked token is still accepted by each API.

Bearer or sender-constrained?

A bearer token is useful to whoever holds it, so its lifetime is its main defence. A token bound with DPoP or mTLS is useless without the private key, which justifies a longer lifetime when the key sits in hardware or a non-exportable store. If the key sits in the same file as the token, binding adds little.

Rotation or absolute expiry for refresh tokens?

Rotation, where each use returns a new refresh token and reuse of an old one revokes the chain, detects theft only if the legitimate client keeps using its token. Absolute expiry limits a stolen token even when the victim is idle. Use both for third-party integrations; some of the tokens used against Gainsight customers had been issued years earlier.

Small and large organisations

  • Small teams: rely on platform defaults where they are already short (STS, GCP, GitHub Apps), remove static cloud keys in favour of federation, and set organisation-wide PAT maximums. That removes most long-lived tokens with little engineering.
  • Large estates: need a token inventory per issuer, the tier mapping above, an exceptions register and automated checks in infrastructure-as-code pipelines that reject a role MaxSessionDuration or token policy above its tier.

Designing for reliability

Most pressure to lengthen lifetimes comes from outages caused by expiry. Fix the cause instead.

  • Renew early: clients should refresh at a fraction of the lifetime (for example at 75 to 80 percent) with jitter, not when the API returns 401.
  • Read expiry from the response: use expires_in or the exp claim. Entra deliberately randomises default access token lifetimes between 60 and 90 minutes, so hard-coded one-hour assumptions fail.
  • Re-read mounted tokens: Kubernetes and similar platforms replace token files in place; libraries that load the token once at start-up fail when it expires.
  • Size long jobs correctly: a batch job that runs longer than its credential must re-assume the role mid-run. Remember AWS role chaining caps sessions at one hour regardless of DurationSeconds.
  • Plan for IdP outages: very short lifetimes make every workload depend on the token service being available. Keep workload lifetimes long enough to ride through a short issuer outage, and monitor issuer health as a dependency.
  • Clock skew: validate with a small leeway (a few minutes). Entra adds a five-minute skew to SAML NotOnOrAfter when a policy applies.

Rolling out a lifetime policy

  1. Inventory issuers and current values. List every IdP, authorisation server, cloud STS, SaaS connected-app setting and developer platform, with current access, refresh and session values. Include vendor-held tokens.
  2. Find the long tail first. Query for refresh tokens and PATs older than your proposed ceiling and grants unused for 90 days. These are usually the biggest risk and the cheapest to remove.
  3. Agree tiers and exceptions. Publish the tier table, the exception process and who approves.
  4. Test in staging with compressed lifetimes. Set lifetimes far below target (for example 10 minutes) in a test environment to flush out clients that cache tokens or ignore expires_in.
  5. Roll out by ring. Apply new values to an application-level policy for a pilot group before the organisation default. In Entra, remember that an organisation-level policy overrides application policies.
  6. Revoke the legacy tokens. Revoke refresh tokens and PATs beyond the ceiling, with notice to owners, and require re-consent for integrations.
  7. Roll back cleanly if needed. Keep the previous policy object and change record; rolling back is reassigning the old policy or role setting, but revoked tokens cannot be restored, so revoke only after the pilot is stable.
  8. Enforce in code. Add policy checks to infrastructure-as-code review so new roles, apps and service accounts inherit the tier ceiling.

Detection and measurement

Log token issuance and use at the issuer and the resource: Entra sign-in logs (including non-interactive and service principal sign-ins), AWS CloudTrail AssumeRole events, Google Cloud audit logs for GenerateAccessToken, Okta system log token events and SaaS API event logs. Watch for refresh tokens used from new networks, access tokens presented after the subject was disabled, and bulk API activity by integrations (ATT&CK T1550.001, Use Alternate Authentication Material: Application Access Token).

  • Long-lived token count: refresh tokens, PATs and API keys older than the tier ceiling. Target zero outside the exceptions register.
  • Median credential age at use: for workloads, how old credentials are when presented. A falling value shows federation is replacing static keys.
  • Dormant grant count: third-party grants unused for 90 days.
  • Time to revoke: from decision to the last accepted use of a revoked token, measured in tests.
  • Expiry-related incidents: outages caused by expired tokens. If this rises, fix renewal logic rather than lengthening lifetimes.
  • Exceptions past their end date: should be zero.

Common failure patterns

  • Setting access token lifetime and ignoring refresh tokens: the Gainsight Salesforce breach involved 285 OAuth tokens created between October 2017 and August 2023; Gainsight's own finding, as reported, was that its tokens had been allowed to live too long.
  • Vendor-held grants with no end date: in the Salesloft Drift breach, customer OAuth tokens stored in one vendor environment kept working until Salesloft and Salesforce revoked all Drift access and refresh tokens on 20 August 2025, after data export had begun on 8 August.
  • Long lifetimes as an outage fix: a pipeline fails at expiry, someone sets the role maximum to 12 hours, and it never comes back down.
  • Exceptions that never expire: service accounts added to a lifetime extension policy for a migration and left there.
  • Classic tokens left unconstrained: an organisation sets a fine-grained PAT maximum but leaves classic PATs with no expiry requirement.
  • Short lifetimes without strict validation: a ten-minute token accepted by every API in the estate is still a ten-minute master key. Pair lifetime with audience restriction.

Where it sits in frameworks

FrameworkReferenceHow a lifetime policy supports it
NIST CSF 2.0PR.AA-01, PR.AA-03, PR.AA-05Credentials for users and services are managed, authenticated and limited
NIST SP 800-53 Rev. 5AC-12, IA-11, SC-23, IA-5Session termination, re-authentication, session authenticity, authenticator lifetime
NIST SP 800-63B-4AAL reauthentication requirementsOverall and inactivity timeouts by assurance level
IETFRFC 9700 sections 2.2 and 2.3Refresh token rotation or binding, audience restriction
MITRE ATT&CKT1528, T1539, T1550.001, T1606.002Token theft, cookie theft, token replay and SAML token forgery that lifetime limits contain

Practitioner checklist

  • Inventory every token issuer and record access, refresh, session and static token lifetimes.
  • Publish lifetime tiers covering privileged, workforce, workload and third-party tokens.
  • Set an absolute lifetime and idle timeout for every third-party refresh token, and revoke grants beyond it.
  • Replace static workload keys with federated or platform-issued credentials of one hour or less.
  • Set organisation maximums for fine-grained and classic personal access tokens.
  • Use Conditional Access sign-in frequency and CAE in Entra rather than legacy refresh token settings.
  • Test client renewal with compressed lifetimes in staging before production changes.
  • Measure time to revoke for each token type, not just whether revocation exists.
  • Keep an exceptions register with owners and end dates, reviewed quarterly.

Standards and references

Related NHI Mgmt Group resources: Token and Session Security Guide · Conditional Access Guide · Workload Identity Federation Guide · SaaS and OAuth App Governance Guide · Machine-to-Machine OAuth (Client Credentials) Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Written and reviewed by Lalit Choda, NHI Mgmt Group. Last updated 24 October 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.