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.
The token answer
POST /api/oauth/token answers:
{
"access_token": "…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "…",
"scope": "read write:memories write:intentions write:changes"
}| Token | Starts with | Lasts |
|---|---|---|
| Access token | xale_ | 1 hour |
| Refresh token | xale_ | 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_, refresh_, client_, 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.
scopecan 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 isinvalid_.scope
Reuse
| What happens | Result |
|---|---|
| Two refreshes with the same token within 10 seconds | The second fails with invalid_; the connection stays. Retry with the newer refresh token. |
| A spent refresh token used later than that | Treated as stolen: the whole connection ends, and every token of it stops working |
| An authorization code used twice | The whole connection ends |
Errors
All are 400 JSON with error and error_.
error | error_ | Do |
|---|---|---|
invalid_ | “The connection lapsed. Connect the app to Xale again.” | Ask the person to connect again |
invalid_ | “The refresh token was already used.” | Use the newest refresh token; if you have none, connect again |
invalid_ | “The refresh token is not valid.” | Connect again |
invalid_ | “This connection was removed. Connect the app to Xale again.” | The person disconnected it, or it was replaced; connect again |
invalid_ | “This Xale account can't be used right now.” | Stop; the account is suspended or gone |
invalid_ | “The authorization code expired. Connect again.” | Codes last 5 minutes; start the sign-in again |
invalid_ | “The PKCE code_verifier does not match.” | Send the verifier that made the code_ |
invalid_ | “The requested scope was not granted.” | Ask for fewer scopes, or none |
invalid_ | “client_id is required.” or “Unknown client.” | Register again |
unsupported_ | “Use authorization_code or refresh_token.” | Fix grant_ |
On the MCP server
An expired, revoked or unknown access token gets 401 with error="invalid_ in WWW-Authenticate. Refresh, then retry the call.
For people
- Checked against main
8aef9b15