Refresh Tokens

Refresh tokens allow clients to obtain new access tokens without user interaction.

Overview

When an access token expires, use the refresh token to get a new one without requiring the user to re-authenticate.

Token Lifecycle

spinner

Token Response

When you receive tokens, note the expiration:

{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "refresh_token": "dGhpcyBpcyBhIHJlZnJlc2g...",
  "token_type": "Bearer",
  "expires_in": 3600
}
Field
Description

access_token

Short-lived token for API access

refresh_token

Long-lived token for renewal

expires_in

Access token lifetime in seconds

Refresh Token Request

POST /token

Headers

Header
Value

Content-Type

application/x-www-form-urlencoded

Authorization

Basic {base64(client_id:client_secret)}

Parameters

Parameter
Required
Description

grant_type

Yes

Must be refresh_token

refresh_token

Yes

The refresh token

scope

Optional

Request subset of original scopes

Example

Response

circle-info

Authority rotates refresh tokens by default. The old refresh token is invalidated when a new one is issued.

Token Rotation

With rotation enabled, each refresh:

  1. Issues a new access token

  2. Issues a new refresh token

  3. Invalidates the old refresh token

This limits damage if a refresh token is compromised.

Implementation

Proactive Refresh

Refresh before expiration:

Reactive Refresh

Refresh when access token is rejected:

Error Handling

Invalid Refresh Token

When this happens, the user must re-authenticate.

Handling Errors

Scope Reduction

Request fewer scopes when refreshing:

You cannot request more scopes than originally granted.

Configuration

Token Lifetimes

Variable
Default
Description

ACCESS_TOKEN_TTL

3600

Access token lifetime (seconds)

REFRESH_TOKEN_TTL

2592000

Refresh token lifetime (30 days)

REFRESH_TOKEN_ROTATION

true

Rotate refresh tokens

Offline Access

To receive refresh tokens, request the offline_access scope:

Security Best Practices

circle-check
circle-exclamation

Revocation

Revoke refresh tokens when:

  • User logs out

  • User changes password

  • Security concern detected

Next Steps

Last updated

Was this helpful?