Skip to content

Every credential ages: access tokens expire in minutes, refresh tokens rotate, application tokens reach their expiry date or get rotated by an administrator, and any of them can be revoked. This page is the operational side of that story for a client author — what expires when, how to refresh and rotate without an outage, and the one property that surprises most integrators: revocation is not instant, because the gateway caches validation results.

Choosing a Credential decides which credential you hold; Authentication & OAuth documents the provider’s full TTL table and grant mechanics; API Tokens documents creating and managing application tokens. This page assumes you have a credential and need to keep it working.

The two credential shapes age on entirely different scales, and a client is designed around whichever clock it lives on:

OAuth bearer tokenApplication token
Typical lifetimeAccess token: 1 hour by default, per-client override (ttl.AccessToken)A calendar expiry date, or unlimited
Kept alive byThe refresh cycle (refresh token: 14 days, rotating)Nothing — it is simply valid until expiry, deactivation or rotation
Renewal actorThe client itself, programmaticallyAn administrator, deliberately
On compromiseRevoke at the providerDeactivate or rotate the owning application user’s token

An OAuth client therefore carries token-refresh machinery as a core component; an application-token client carries none, and instead needs an operational answer to “what happens on the day the token rotates”.

Access tokens are short-lived by design; the refresh token is what persists. Grants that yield refresh tokens, rotation policy and TTLs are specified and documented in Authentication & OAuth; what matters to a running client is the discipline:

  • Always store the refresh token from the last response. Rotation means a refresh response may carry a new refresh token that silently replaces the one you used — public web clients rotate on every use, and every client rotates once a token passes 70% of its lifetime (rotateRefreshToken). Reusing a rotated-away token fails.
  • Rotation is not immortality. Total rotated lifetime is capped at one year, and a rotated public-client token inherits the remaining TTL of its predecessor rather than restarting the 14-day clock.
  • Refresh proactively, not reactively. The token response’s expires_in tells you when the access token dies; refreshing shortly before that beats racing a 401 in production. When you do receive a 401 mid-flight, one refresh-and-retry is the correct recovery; a second 401 means the session is genuinely gone and the client must re-authenticate.

Since 1.8 — an application token’s expiry date is enforced at validation time. The stored expiresAt is a calendar date (yyyy-MM-dd), and the token remains valid through the end of that day (UTC); a token flagged unlimitedExpiry, or with no date set, never expires (isTokenExpired). An expiresAt value that does not name a real calendar date is treated as expired — the check fails closed and logs the bad value rather than granting an accidental immortal token.

Practical consequences:

  • Expiry is a day boundary, not a timestamp. Plan rotations for the day before, not the hour before.

  • A token that stopped working on schedule is not an incident; regenerating it (below) both issues a fresh secret and re-synchronizes the expiry fields from the application user’s entry.

  • An expiry can actually be set Since 1.10. Before 1.10 the application user form kept its Expiry date field hidden, so every token was created without an expiry and never expired. The field is now a date (yyyy-MM-dd), shown unless Unlimited expiry is on. An entry whose expiry was stored as a full timestamp is treated as expired until the date is re-entered — see API Tokens.

Since 1.8 — an administrator can regenerate an application’s token from the admin area. Regeneration issues a new secret, emails it to the requesting administrator, and — this is the part that makes zero-downtime rollover possible — keeps the previous token valid for a grace window (regenerateApiToken). The window is deployment-configured via APP_TOKEN_GRACE_PERIOD_MS, defaulting to 24 hours; setting it to 0 revokes the replaced token immediately.

The rollover procedure that follows from the mechanism:

  1. Regenerate. The old token keeps authenticating; nothing breaks yet.
  2. Deploy the new secret to the integration within the grace window.
  3. Verify traffic on the new token before the window closes — the token record tracks lastUsedAt, so an integration still on the old secret is discoverable.

One sharp edge, directly from the code: the record remembers exactly one previous hash. Regenerating twice in quick succession overwrites the first grace entry — the token your integration is still running on — and revokes it on the spot. Rotate, migrate, verify, and only then rotate again. (Since 1.10 two concurrent regenerations are serialised per application across pods, so they can no longer both rotate from the same token; the sequential case above still applies.)

For OAuth credentials the provider exposes the standard revocation endpoint (/token/revocation, enabled features); revoking a refresh token ends the session’s ability to renew, and an access token can be revoked individually.

An application token is revoked through its owning application user’s entry, in either of two strengths:

  • Deactivate the application user — the update handler flips the token’s isActive off; reactivating restores it.
  • Archive the entry — the token document is soft-deleted and stops validating permanently; records are retained for audit, never hard-deleted.

Both take effect at the identity service immediately. Whether the gateway still honours the token for a while longer is the next section.

The gateway caches successful validations in Redis so that steady-state traffic costs no identity-service round-trips. The same cache means a credential revoked at the provider can keep authenticating at the edge until its cached entry dies. The two paths cache differently — both TTLs sit in the plugin schemas and are deployment-configurable; the shipped configuration (api-gateway/config/kong.yml) overrides neither, leaving the defaults:

PathCached resultTTLExpiry honoured from cache?
OAuth bearer (oauth2-introspection plugin)The introspection responsecache_ttl, default 300 s, additionally capped to the token’s remaining lifetime minus 10 s; tokens within 30 s of expiry are not cached at allYes — a cached entry past the token’s exp is evicted (with a 5-second clock-skew buffer) and re-introspected
Application token (app-token-auth plugin)The validation resultcache_ttl, default 300 sNo — a cache hit is trusted as-is for the full TTL; nothing is re-checked until it lapses

Read the table as a client author and as an operator:

  • Expiry is prompt; revocation is eventually consistent. An expired bearer stops at the edge within seconds, but a revoked-yet-unexpired bearer — and a deactivated or freshly-rotated-away application token — can continue to authenticate for up to the configured cache_ttl after revocation.
  • The lag bound is a deployment choice. It equals the plugins’ cache_ttl (300 s as shipped), and on the OAuth path is further capped by the token’s own remaining lifetime. A deployment with stricter revocation requirements sets a smaller cache_ttl and pays for it in validation traffic.
  • Authentication is not the only cached thing: what a user is permitted to do is cached separately and on longer clocks — see the cache table in Tenancy and Identity.

The lifecycle facts above compress into a small set of client rules. Refresh OAuth sessions ahead of expiry and treat a single 401 as a refresh trigger, not a failure. Persist whichever refresh token arrived last. For application tokens, schedule rotation ahead of the expiry day, complete rollovers within the grace window, and never assume a revoked credential died instantly anywhere — build de-provisioning flows on the identity source (deactivate the user, revoke the session) and let the edge caches drain in their own bounded time.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27