Connect and sign in

Tokens Expiry and refresh

Access tokens last an hour. Refresh tokens rotate on every use, and a connection nobody uses lapses after 60 days. Reusing an old refresh token ends the whole connection.

View as Markdown

The token answer

POST /api/oauth/token answers:

json
{
  "access_token": "…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "…",
  "scope": "read write:memories write:intentions write:changes"
}
TokenStarts withLasts
Access tokenxale_at_1 hour
Refresh tokenxale_rt_Until used; unused, 60 days

Both are opaque random strings; Xale stores only their SHA-256. Send the access token as Authorization: Bearer … on every /api/mcp call; Xale reads it from that header only.

Refreshing

POST /api/oauth/token, form-encoded: grant_type=refresh_token, refresh_token, client_id, and optionally scope.

  • Every refresh returns a new access token and a new refresh token. Keep the new refresh token: the old one is spent.
  • A connection lapses when its refresh token goes 60 days unused.
  • scope can keep or narrow what the connection holds. Leave it out (or send only identity scopes) to keep everything. Asking for a scope the connection doesn't hold is invalid_scope.

Reuse

What happensResult
Two refreshes with the same token within 10 secondsThe second fails with invalid_grant; the connection stays. Retry with the newer refresh token.
A spent refresh token used later than thatTreated as stolen: the whole connection ends, and every token of it stops working
An authorization code used twiceThe whole connection ends

Errors

All are 400 JSON with error and error_description.

errorerror_descriptionDo
invalid_grant“The connection lapsed. Connect the app to Xale again.”Ask the person to connect again
invalid_grant“The refresh token was already used.”Use the newest refresh token; if you have none, connect again
invalid_grant“The refresh token is not valid.”Connect again
invalid_grant“This connection was removed. Connect the app to Xale again.”The person disconnected it, or it was replaced; connect again
invalid_grant“This Xale account can't be used right now.”Stop; the account is suspended or gone
invalid_grant“The authorization code expired. Connect again.”Codes last 5 minutes; start the sign-in again
invalid_grant“The PKCE code_verifier does not match.”Send the verifier that made the code_challenge
invalid_scope“The requested scope was not granted.”Ask for fewer scopes, or none
invalid_client“client_id is required.” or “Unknown client.”Register again
unsupported_grant_type“Use authorization_code or refresh_token.”Fix grant_type

On the MCP server

An expired, revoked or unknown access token gets 401 with error="invalid_token" in WWW-Authenticate. Refresh, then retry the call.

  • Checked against main 8aef9b15

Was this helpful?

tokens-expiry-and-refresh.md · main@c1725f34