part 2OAuth 2.1 from scratch·lesson 2.9 of 10·2 min read
Refresh tokens and offline_access
Refresh tokens let an OAuth client keep working when its access token expires, without bothering the user. This lesson shows how a refresh token is used, what refresh token rotation is and why it matters for public clients, and what MCP 2026-07-28 says about the offline_access scope.
In this lesson
Use a refresh token to obtain a new access token.
Explain refresh token rotation and why it matters for public clients.
State what MCP 2026-07-28 says about offline_access.
Renewing with a refresh token
Renewal with a refresh token (and rotation)
1. Request with an expired token
Client → MCP server
The MCP server responds 401 with error="invalid_token". (Better still: the client renews ahead of time by watching expires_in.)
With rotation, the authorization server issues a new refresh token and invalidates the previous one. If someone tries to use the old one, the AS detects the theft and can revoke the whole chain.
4. Retry
Client → MCP server
With the new access token, the request succeeds.
Storing refresh tokens
In the operating system's secure store (macOS Keychain, Windows Credential Manager, libsecret), not in a plain-text JSON file.
Bound to the authorization server that issued them (MCP 2026-07-28: client credentials are bound to their AS and are not reused with another one).
offline_access
A scope that comes from OpenID Connect: "I want to be able to access even when the user is not present", which in practice means "give me a refresh token". MCP 2026-07-28 mentions it explicitly: the client may request it, and the MCP server should not require it (it is a matter between the client and the AS, not a requirement for using tools). In the same spirit, the MCP server should not list it in its scopes_supported or in the scope of its WWW-Authenticate challenges.
Summary
Refresh token → POST /token with grant_type=refresh_token (and resource).
Rotation: each use returns a new refresh token and invalidates the previous one; a replayed old token reveals theft.
Store refresh tokens in the OS secure store, bound to the AS that issued them.
offline_access: optional for the client, not something the MCP server should require.
quiz · 2 questions
1. With refresh token rotation, an attacker steals the old refresh token after the legitimate client has already used it. What happens if the attacker uses it?
That is precisely the goal of rotation for public clients: a used refresh token is no longer valid, and its reuse signals theft.
2. Under 2026-07-28, must an MCP server reject tokens that do not include offline_access?
offline_access is used to obtain refresh tokens from the AS; it adds nothing for the MCP server.