Tokens and sessions
What access and refresh tokens do, why a refresh token changes every time you use it, and what ends a sign-in.
On this page
When someone signs in to your app, we give you two tokens. The access token says who the account is and lives for a short time. The refresh token lets your app get a new access token without asking them to sign in again.
This page explains how long each one lives, why refresh tokens change every time you use them and what ends a sign-in. For the API calls, see Exchange, refresh, check and revoke tokens.
Three sessions, three owners
| Session | Lives in | Lasts | Ended by |
|---|---|---|---|
| Silicon Accounts' browser session | An HttpOnly cookie on accounts.teamofsilicons.com | up to 900 days | The Carbon signing out on the account site, or removing it from their sessions list |
| Your app's sign-in (a token family) | Your server: the refresh token and the access tokens it mints | up to 900 days from the sign-in (a Silicon's sign-in made from a CI job ends with the job's sign-in) | Your app revoking it, the account removing your access, a Silicon's STK rotation, removing the CI trust it came from, account deletion, token reuse, or its end |
| Your app's own session | Whatever you use (usually your own cookie) | You decide | You |
They are independent on purpose. Signing out of your app (revoking) doesn't sign the browser out of Silicon Accounts, because the Carbon may be signed in to ten other apps there. Signing out of Silicon Accounts doesn't end your app's sign-in either, because your app decides how long its users stay signed in. The one link that matters runs one way: when your sign-in ends for a reason you didn't cause, we tell your webhook and you end your own session.
Since the browser session outlives your sign-in, a Carbon who signs out of your app and clicks "Sign in" again is offered "Continue as …" without a code. Send prompt=login when signing back in must mean proving it again.
Access tokens: short and self-contained
An access token is a JWT signed with Ed25519 (alg: EdDSA), issued to your app (aud is your app id) for 30 minutes, or until its sign-in ends if that comes sooner: an access token never outlives its sign-in. It carries everything an API needs to decide who is calling: the account's uuid (sub), its kind, its id when the token was issued, the membership id, the sign-in it belongs to (fid) and the granted scopes.
- Self-contained, so your API can verify it with the public keys at
/.well-known/jwks.jsonwithout calling us on every request. Keys are named bykid. Cache the key set, and fetch it again when a token names a key you don't have. - Short, because a self-contained token can't be called back: once issued, it verifies until
exp. Thirty minutes caps how long an API that only checks locally can still accept a revoked sign-in. When an action can't wait that long (deleting data, moving money), ask introspection. It knows about revocation right away, and it also refuses tokens whose membership is no longer active. - Audience-bound, so a token minted for one app is useless at another. Your API must check
aud; the libraries do it when you pass your app id. To act at another app on an account's behalf, apps use User verification proofs, never each other's tokens.
Refresh tokens: rotated, reuse-detected, 900 days at most
A refresh token is opaque (sar_…). Token lookup uses a keyed hash; recoverable refresh replies
are also stored encrypted with a 24-hour recovery window; expired ciphertext is cleared by the background sweep. A database copy alone reveals no token. Three rules shape it:
- It rotates. Each new refresh operation gives you a new refresh token and spends the old one.
- Unrecognized reuse ends the sign-in. A spent token presented without its original refresh operation key revokes the whole family, newest tokens included, and tells your app (
membership.signed_out, reasonrefresh_token_reuse). A recognized retry can recover the already-issued tokens while the successor is unused, within 24 hours, after current authorization is checked. - 900 days, then sign in again. The limit counts from the moment the account signed in, and refreshing doesn't extend it. A sign-in that starts with an earlier end keeps that end: a Silicon's sign-in made from a short-lived token its CI job minted ends with the job's sign-in. A sliding window would let a stolen token live forever as long as someone keeps using it; a fixed one puts an end on every sign-in.
Persist one random Idempotency-Key with each pending rotation and share it across workers and
tabs. Duplicate requests for that operation rotate once; an in-progress request returns a
retryable conflict. Save the returned tokens atomically before using them, checking the session
version so a late answer cannot overwrite a later refresh or logout. A process-local lock alone
does not coordinate multiple servers. Refresh recovery
also covers lost replies, restart recovery, and expired recovered access tokens. Unkeyed clients
retain the old behavior and need an update to use this protection.
What ends a sign-in
| Event | Your webhook hears | A refresh then says (invalid_grant) |
|---|---|---|
| Your app revokes the refresh or an access token | membership.signed_out, reason app_revoked | … was revoked at … (app_revoked) |
| A spent refresh token is presented again | membership.signed_out, reason refresh_token_reuse | … (refresh_token_reuse) |
| A used authorization code is presented again | membership.signed_out, reason authorization_code_reuse | … (authorization_code_reuse) |
| The account removes your app's access on the account site | membership.access_removed | … (access_removed) |
| A Silicon's custodian rotates its STK | membership.signed_out, reason stk_rotated | … (stk_rotated) |
| A Silicon's CI trust is removed, for a sign-in made from a short-lived token its CI sign-in minted | membership.signed_out, reason session_revoked | … (federation_removed) |
| The account is deleted | account.deleted | … (account_deleted) |
| 900 days pass, or the CI sign-in a Silicon's sign-in came from ends | nothing | The refresh token expired at … |
When an account removes your access, we revoke every sign-in your app holds for it (and the User verification proofs your app issued about it), mark the membership access_removed in your user base, and stop showing you its contact details. They come back only when the account signs in to your app again, through the what's-shared screen.
The access tokens of an ended sign-in keep verifying locally until their exp, at most 30 minutes. Introspection answers {"active":false} for them at once, and /v1/userinfo refuses them with token_revoked and the reason.
Codes and short-lived tokens: one use, two minutes
Both are bearer credentials that pass through places your server doesn't control (a URL, a Silicon's terminal), so we keep both as narrow as we can:
- An authorization code is bound to your app, the redirect URI and the PKCE challenge of its request. It works once and expires after 120 seconds. Its exchange and the tokens it issues happen in one transaction, so of two exchanges at the same moment exactly one wins, and the loser's attempt revokes the winner's tokens (the code had leaked).
- A short-lived token (
slt_…) is how a Silicon signs in to your app. The Silicon's own signed-in session mints it for one app. It works once and expires after 120 seconds. We refuse it if the Silicon's STK was rotated after it was minted (rotation ends every sign-in of the Silicon, tokens already handed out included), or if the account removed your app's access after it was minted. One minted by a Silicon's sign-in from a CI job starts a sign-in that ends when that CI sign-in was set to end, and is refused once its trust was removed or that end has passed. Signing the CI sign-in out or revoking it doesn't refuse one it already minted, which expires within 2 minutes anyway. Removing the trust later ends that sign-in too, but signing the CI sign-in out doesn't: your sign-in still runs to the CI sign-in's end (CI and cloud). Your server exchanges it with your app secret; your own command-line or desktop tool may exchange it with yourclient_idalone if your app turned onpublic_client.
The id_token is for your client, not for APIs
With openid in the scope, the token response also carries an id_token. It's a statement to your app about who signed in and when (auth_time), with your nonce so nobody can replay it into another sign-in. It's for the code that handled the callback. Don't send it to APIs as a credential; the access token is the credential. Refreshes return a new id_token without a nonce, and auth_time stays the time of the original proof.
Scopes over time
We remember which details an account has agreed to share with your app, across sign-ins. Asking for fewer details in a later sign-in doesn't take back the earlier agreement. The scope in the token response tells you what's granted right now.
A Carbon can shrink that grant by turning off optional details on the what's-shared screen, or by removing your app's access. To show them the what's-shared screen again, ask for more details or use prompt=consent. A refresh can ask for less, but it can't add a new grant: new details always go through the what's-shared screen.
Keep tokens on your server
- Your app is a confidential client unless you say otherwise. Exchanging a code needs your app secret, so the exchange happens on a server you control, and single-page apps hand the code (or the code and verifier) to that server. Desktop apps and CLIs can't keep a secret, so you can turn on
public_client: they then redeem codes with PKCE (S256) and exchange a Silicon's short-lived token withclient_idalone (that sign-in is recorded with the methodslt_public_client), and the device flow (device_flow) works for tools with no browser at all. Withoutpublic_client, a Silicon's short-lived token is exchanged with the app secret, so a CLI that Silicons use forwards it to a backend (CLI plus backend). - Refresh tokens are long-lived credentials. Keep them on your server, encrypted at rest, never in
localStorageor a URL. Give the browser your own session cookie instead. - Access tokens may reach the browser if your pages call your API with them, but every copy is a 30-minute credential for that account at your app.
How we protect things on our side (hashing, encryption, cookie rules, what we never log) is in Security.