# Sign in with OnlyWorlds

A tool can sign a person in through onlyworlds.com instead of asking for their email and password. The tool sends the browser to onlyworlds.com, the person signs in there (and presses Continue: once for a tool on the list below that returns to one of its `https://` addresses, at every sign-in for any other), and the browser comes back to the tool with a code. The tool trades the code once for an `ow_a_` [account token](/docs/getting-started/keys#account-tokens). The tool never sees a password.

1. **Send.** The tool sends the browser to `GET /signin/authorize` on www.onlyworlds.com with `client_id`, `redirect_uri`, `state`, `code_challenge`, `code_challenge_method=S256`.
2. **Ask.** The person signs in, if they are not. No consent yet for this tool: Continue or Cancel. A refused request gets a `400` page, no redirect.
3. **Return.** A `302` sends the browser back to `redirect_uri?code=…&state=…` (Cancel: `redirect_uri?error=access_denied&state=…`); the code: 60 seconds, one exchange. The tool checks `state`.
4. **Trade.** The tool posts `grant_type`, `code`, `code_verifier`, `client_id`, `redirect_uri` to `POST /api/v2/auth/token`, no credential. The answer, `200`: `token` (`ow_a_…`), `token_id`, `token_type`, `expires_at`, `account`.

Generated from the API's own document (`openapi.json`), as read on 2026-11-14: the authorize page's address and parameters, the token route, its fields and the code's lifetime.

It is OAuth 2.1's authorization code flow with PKCE (`S256`), for public clients: no client secret, no refresh token, and one optional scope, [`world:read`](#a-read-only-token). The token is an ordinary account token, with the same reach as one the person mints themselves. It adds a door and replaces nothing: email and password, and world keys, keep working.

## Registered tools

A tool on this list signs a person in with the flow on this page. An AI assistant's connector registers itself instead, is not on the list, and has a door of its own ([AI assistants](#ai-assistants)). `GET /api/v2/auth/clients` lists the registered tools, with no credential:

```bash
curl -s "https://www.onlyworlds.com/api/v2/auth/clients"
```

```json
{ "clients": [ { "id": "atlas", "name": "Atlas",
    "redirect_uris": ["https://atlas.onlyworlds.com/signin/callback"],
    "native": false } ] }
```

| Field | Meaning |
|:--|:--|
| `id` | The `client_id` the tool sends |
| `name` | The tool's name, as the Continue page and the token's name show it: a token for a tool in a browser is named with the browser (Atlas on Chrome), a native app's by this name alone |
| `redirect_uris` | The exact return addresses: a `redirect_uri` must equal one of them byte for byte, except a native app's loopback ones (below) |
| `native` | `true` for a desktop or mobile app, `false` for every other tool |

The answer is sent `Cache-Control: public, max-age=60`, so a removed address stops being served within a minute. The list is kept by OnlyWorlds: a tool can be added once it is on the tools list ([List your tool](/docs/development/list-your-tool)).

**Return addresses.** A web tool's are exact `https://` addresses. A native app's (RFC 8252) may also be:

- **a loopback address**, `http://127.0.0.1/<path>` or `http://[::1]/<path>`, listed with no port. The app picks its port when it runs, and a `redirect_uri` on the same host and path matches with any port from 1 to 65535. `localhost` is never accepted: a name can resolve somewhere else.
- **a custom scheme**, matched exactly: a reverse-DNS scheme such as `com.example.app://callback`, or a known app's (`obsidian://`). `http`, `https`, `javascript`, `data` and `file` are never a custom scheme.

Three native clients are registered: the [Obsidian plugin](/docs/tools/obsidian-plugin) (`obsidian`, shown as OnlyWorlds Builder), with `http://127.0.0.1/onlyworlds-signin` and `obsidian://onlyworlds-signin`, and the OnlyWorlds desktop app (`onlyworlds-desktop`, shown as OnlyWorlds app, since 2026-11-30), with `http://127.0.0.1/signin/callback`; and every game made with the engine packages (`worlds-only-games`, since 2026-12-01), with `http://127.0.0.1/signin/callback`. The Continue page names no game, only "a game", since OnlyWorlds cannot tell which game is asking, and the game's token [reads worlds only](#a-token-that-reads-worlds-only). A native app is asked to press Continue at every sign-in. Since plugin 3.15.0 it signs in this way on desktop, through the loopback return; on a phone the button is hidden until the `obsidian://` return has been walked there.

## Sending the person to sign in

The tool sends the browser to `https://www.onlyworlds.com/signin/authorize` with five query parameters:

| Parameter | Meaning |
|:--|:--|
| `client_id` | The tool's `id` in the registry |
| `redirect_uri` | One of that tool's registered return addresses, byte for byte: no tolerance for a trailing slash, a case change or an added query. A native app's loopback address takes the port it chose |
| `state` | The tool's own opaque value, up to 1024 characters, sent back untouched |
| `code_challenge` | The PKCE challenge: the base64url SHA-256 of a verifier the tool keeps |
| `code_challenge_method` | `S256`. `plain` is refused |

A tool that only reads may add a sixth, `scope=world:read`, for a [read-only token](#a-read-only-token) (since 2026-11-14). It is the one value there is for a tool: any other answers the `400` page below. (An [AI assistant's connector](#ai-assistants) to the MCP server may ask for two.)

What the person sees:

- **Signed in, has pressed Continue for this tool before, and the tool returns to one of its `https://` addresses on the list:** nothing. A `302` sends the browser straight back to `redirect_uri?code=…&state=…`.
- **Signed in, any other sign-in:** the first for such a tool, and every one for a native app or a [connector that registered itself](#ai-assistants) (since 2026-11-30, when these were asked once too): one page asking whether the tool may sign in as them, with Continue and Cancel. Continue sends the code back; Cancel sends `redirect_uri?error=access_denied&state=…`.
- **Not signed in:** the sign-in page first, then the same.

A request onlyworlds.com cannot trust is never redirected. A missing or unknown `client_id`, a `redirect_uri` not on that tool's list, a `code_challenge_method` other than `S256` (`plain` or none), a `code_challenge` that is not 43 base64url characters, a `state` that is missing, empty or over 1024 characters, or a parameter named twice answers a `400` page on onlyworlds.com that says what is wrong, with no `Location` and no code. These checks come first, so a signed-in person gets the same page. Every answer from this page, the redirect included, is sent `Cache-Control: no-store` and `Referrer-Policy: same-origin`.

## Trading the code

The tool's return page checks that `state` is the one it sent, then posts the code once to `POST /api/v2/auth/token`, as JSON, with no credential:

```bash
curl -s -X POST "https://www.onlyworlds.com/api/v2/auth/token" \
  -H "Content-Type: application/json" \
  -d '{ "grant_type": "authorization_code", "code": "…", "code_verifier": "…",
        "client_id": "atlas", "redirect_uri": "https://atlas.onlyworlds.com/signin/callback" }'
```

| Field | Meaning |
|:--|:--|
| `grant_type` | `authorization_code` |
| `code` | The code from the return address |
| `code_verifier` | The PKCE verifier, 43 to 128 characters, whose S256 hash was the `code_challenge` |
| `client_id`, `redirect_uri` | Exactly as the authorize request sent them |
| `ai_uses` | Optional: also an [AI door token](#an-ai-door-token) for these AI uses, 1 to 8 by slug |
| `ai_lifetime_minutes` | Optional, with `ai_uses` only: that token ends this many minutes after the exchange (1 to 1440), or at midnight UTC if that comes first |

```json
{ "token": "ow_a_…", "token_id": "…", "token_type": "bearer", "expires_at": null, "account": { "id": "…", "username": "…" } }
```

The answer is sent `Cache-Control: no-store`. `expires_at` is when the token stops working, for a tool whose registration asks for a lifetime (1 to 720 hours; Little Lens's tokens last six), and 720 hours for [a client that registered itself or a game](#a-token-that-reads-worlds-only); null for a listed tool with none, whose token works until it is revoked. An expired token is refused as a revoked one is, the same 401. `token` is shown only here: the tool keeps it and sends it as `Authorization: Bearer ow_a_…` on the [account routes](/docs/getting-started/keys#account-tokens), such as [managing members](/docs/development/api/members#managing-members), and to [read a world's elements](/docs/getting-started/keys#reading-a-world-with-an-account-token) as the person's own access there, with no key minted. On the person's account page, under Account tokens, it is listed by the tool's name and the browser (`Atlas on Firefox`), and they can revoke it there. `token_id` (since 2026-10-25) is the token's id: a tool done with the token revokes it with `DELETE /api/v2/account/tokens/{token_id}`, sending the token itself as the bearer. That revoke ends the tool's consent only when it was the tool's last live token for the person, or for a tool that asks each time ([Consent and revoking](#consent-and-revoking)).

**A code lives 60 seconds and is spent by its first exchange,** whether that succeeds or fails. A code sent again is refused and also revokes the token its first exchange minted: a replayed code is treated as a stolen one. So take `code` out of the address bar before the exchange, and send the exchange before any other request: a reload would spend the code on a refusal.

### An AI door token

A tool that calls the [AI door](/docs/development/ai#the-ai-door-a-use-by-name) for the person can ask the exchange for a token that opens nothing else (since 2026-11-09), with `ai_uses` in the body (the uses by slug, as `GET /api/v2/account/ai` lists them). A use named twice is kept once, where it first stands (the limit of 8 counts the list as sent). The answer then carries the AI door token beside the account token; its own `ai_uses` is what the server took, so read that, never the list you sent:

```json
{ "token": "ow_a_…", "token_id": "…", "token_type": "bearer", "expires_at": null, "account": { "id": "…", "username": "…" },
  "ai_token": { "token": "ow_a_…", "token_id": "…", "token_type": "bearer", "audience": "ai", "ai_uses": ["ask"], "expires_at": "2026-11-10T00:00:00Z" } }
```

It calls `GET /api/v2/account/ai`, which lists only the uses it names, and those uses, as the person and on their token rating. A use it does not name answers `403` [`use_not_granted`](/api/errors/#use_not_granted), and every other route `401` [`wrong_audience`](/api/errors/#wrong_audience). It ends at the next midnight UTC, or sooner with `ai_lifetime_minutes`. The two tokens are independent: the tool may revoke the account token at once and keep the AI door token for its calls. The AI door token revokes itself with `DELETE /api/v2/account/tokens/{token_id}`, sent as its own bearer, and touches no other token, consent or key. It never counts as one of the tool's live tokens for consent or keys. Disconnecting the tool and a replayed code end it. An `ai_uses` that is not 1 to 8 uses this server runs is a `422` with `param` `ai_uses` (an `ai_lifetime_minutes` out of range, `param` `ai_lifetime_minutes`), and the code is spent. In the TypeScript SDK (4.141.0 on), `completeSignIn` throws it as `OwSignInError` with reason `failed`, its `status`, `code` and `param`, so a tool can tell it from any other refusal of the exchange.

### A read-only token

A tool that only reads, such as a map viewer, can ask for a token that cannot write (since 2026-11-14): `scope=world:read` on the authorize request. The Continue page then says the sign-in reads only, and the exchange's answer carries `scope`:

```json
{ "token": "ow_a_…", "token_id": "…", "token_type": "bearer", "expires_at": null, "account": { "id": "…", "username": "…" }, "scope": "world:read" }
```

An answer with no `scope` is a token that writes as the account does, so a tool that asked for read-only reads the field rather than assuming it. The token reads everything the person's account reads. Every write with it (a world key minted, a world made, another token minted, an AI call) is a `403` [`permission_error`](/api/errors/#permission_error): "This token is read-only: it was signed in with scope world:read and cannot write. Sign in again without that scope, or use a write key with its PIN." The one write it makes is revoking itself with `DELETE /api/v2/account/tokens/{token_id}`; another token's id is the same `403`. It gets no AI door token: `ai_uses` with a read-only code is a `422` with `param` `ai_uses`, and the code is spent. `GET /api/v2/account/tokens` lists it with `scope: "world:read"`, a key absent on every other token, and the account page marks it read-only.

A read-only Continue covers only read-only sign-ins: the tool's first sign-in for the whole account shows the Continue page again, and that Continue then covers both.

### A token that reads worlds only

Two kinds of client get an account token that reads worlds and nothing else, whatever scope they ask for (since 2026-12-01): a client that registered itself (its `client_id` starts `dyn-`, see [AI assistants](#ai-assistants)) when it trades its code at the exchange above, and a game made with the engine packages, which signs in as `worlds-only-games` ([Registered tools](#registered-tools)). The answer says `scope: "world:read"`, and `expires_at` is 720 hours after the exchange; there is no refresh, so the game or tool offers the sign-in again after that. `GET /api/v2/account/worlds` lists the account's worlds with no `keys` on any row (the field is absent, never an empty list). In a world it names with `world`, the token reads the world, an element type's list, one element, search, metadata and the [change feed](/docs/development/api/changes) (since 2026-12-01). It may revoke itself. Every other route that takes an account token answers it `403` [`permission_error`](/api/errors/#permission_error), and `ai_uses` on its exchange is a `422`. Every other tool on the list signs in as before, a read-only one included.

## The account

With the token, `GET /api/v2/account` reads the account itself: `id`, `username`, `email`, `date_joined`, and its **OnlyWorld**, the one world that stands for the account. `only_world` is `{ id, name, slug }`: the world the person chose, or, until they choose one, the oldest world the account owns (the first it created), or `null` while it owns none. `only_world_chosen` is true for a choice and false otherwise. When the chosen world is deleted, the oldest world left serves in its place. Only the account's own credential reads it: no world key, member or public reader does.

`PATCH /api/v2/account` changes `username`, or the OnlyWorld with `only_world`: the id of a world the account owns, or `null` to clear the choice so the oldest world serves again. An id that names no world of the account's is a `404`, and nothing in the body is written. It answers the account as the `GET` does. The person can make the same choice on the site.

A new `username` follows the rule sign-up follows: only the letters a to z (small or capital), the digits 0 to 9 and `. + - _` (no `@` since 2026-12-01), with at least one letter or digit; at most 30 characters; not another account's name, ignoring case; and never the word `owner`, in any case. A name the rule refuses is a `422` [`invalid_request`](/api/errors/#invalid_request) with `param` `username` and a sentence that says why, and nothing in the body is written. The account's own name sent back unchanged is kept as it is, and changing only the case of one's own name is not refused as taken. Names made before the rule (2026-11-11) stay as they are, and so does a name that already holds an `@`: it keeps working.

`GET /api/v2/account/worlds/holding/{element_id}` says which of the account's own worlds holds an element, so a page or a tool that sent elements to be made into a world can ask where they went (since 2026-11-01 for a Narrative's id, since 2026-11-07 for any element's): `200` with `world_id` and `door` (the world's page on onlyworlds.com, a path on this host) when a world the account owns holds that element, and one identical `404` [`not_found`](/api/errors/#not_found) for anything else (a stranger's element, one in a world the account only has a seat in, an unknown or malformed id). A tool that sent its call with an `Idempotency-Key` asks [by the key](/docs/getting-started/keys#a-world-with-its-first-elements) first: a world that holds one of the ids may be an older world of the account's. Any account credential, the site's session included.

## Errors

| Status | Code | When |
|:--|:--|:--|
| `400` | [`invalid_grant`](/api/errors/#invalid_grant) | The code is unknown, used, expired, or was issued for another `client_id`, `redirect_uri` or `code_verifier`. One body for every case, byte for byte. Start the sign-in again |
| `422` | [`invalid_request`](/api/errors/#invalid_request) | The body is not JSON (a form-encoded body included) or not an object, a field is missing or not text, or `grant_type` is not `authorization_code`. `param` names it. A code in a form-encoded body or a JSON object is spent |
| `429` | [`rate_limited`](/api/errors/#rate_limited) | Too many sign-in attempts from this address: this route and the password sign-in share one count, 40 in 5 minutes. Wait the `Retry-After` seconds. The body is not read, so the code is not spent |
| `429` | [`too_many_requests`](/api/errors/#too_many_requests) | Over the request budget, as on every route ([Limits](/docs/development/api-reference#limits)) |

The authorize page's refusals are pages, not API errors: see [Sending the person to sign in](#sending-the-person-to-sign-in).

## Consent and revoking

For a tool on the list that returns to one of its `https://` addresses, the Continue page appears once per account and tool, except for a tool that asks each time (below). After that, the tool's sign-ins to those addresses pass with no page until the consent ends, which happens in three ways (every other sign-in, a native app's or a self-registered connector's, shows the page each time, since 2026-11-30):

- **The tool's last token revoked.** Revoking a token a tool got through Sign in with OnlyWorlds, on the account page or with `DELETE /api/v2/account/tokens/{token_id}` (the [TypeScript SDK](/docs/development/typescript)'s `revokeAccountToken`, since 4.122.0, by the `tokenId` the sign-in answered), revokes that token only (since 2026-10-25). The consent ends when the person holds no other live token from that tool's sign-ins; then its next sign-in shows the Continue page again. So a tool can replace its token, signing in again and revoking the old one, without being asked again. A tool whose registration asks for it keeps the consent through its own sign-outs, whatever its tokens: one that holds its token in memory only and revokes it when you leave, such as Little Lens, does not ask you to Continue on every visit; only Disconnect ends its consent (since 2026-10-27). The revoke a replayed code causes counts the same way.
- **Disconnect.** The account page lists, under Tools you signed in to, every tool with a consent, a live token, or a live world key one of its tokens minted (since 2026-12-01), with its count of live tokens and keys and a Disconnect button. Disconnect revokes every live token the tool's sign-ins hold for the account and ends the consent, and every live world key the tool minted with those tokens (2026-10-26), kept keys included; tokens and keys minted by hand, on the site or by other tools are untouched. It also ends a sign-in the tool started for the person and has not finished: that code then answers [`invalid_grant`](/api/errors/#invalid_grant) (since 2026-12-02). With an account token it is `DELETE /api/v2/account/clients/{client_id}` ([below](#disconnecting-a-tool)).
- **A tool taken off the registry.** It loses every person's consent at the next deploy of onlyworlds.com. If it is ever listed again, each person is asked again.

**The keys a token minted** (since 2026-10-27). Revoking a sign-in token also revokes the world keys it minted, in any world, in the same step, unless the person holds another live token of the same tool that is not read-only: then the keys pass to the tool's newest such token and go with its last. A chat app's grant on the MCP server and an [AI door token](#an-ai-door-token) never take keys (since 2026-12-01). Three kinds of key outlive the token: a key minted with `keep: true` on `POST /api/v2/account/worlds/{world_id}/keys` (a tool that stores a key on the device, such as Atlas or Lantern, passes it, and takes the key back when the world leaves the device); the keys of a token made by hand or through a password sign-in (the Obsidian plugin's); and the keys of a tool that asks each time. A world's first key, minted with the world, records no token and is never swept. A sign-in code used twice takes every key its token minted, kept or not. `GET /api/v2/account/tokens` gives each token's `keys_minted`, its live keys.

**A tool that asks each time.** The [Council](/docs/tools/council) and [Tactical Tangle](https://tangle.onlyworlds.com) need their token only to mint a world key, then revoke it, and the registry marks them as asking each time: any revoke of one of their tokens ends the consent, so a token left behind (a tab that closed first) never keeps it. They show the Continue page on every sign-in, and the page says so. The mark is the registry's own; `GET /api/v2/auth/clients` does not serve it.

What ties a token to its tool is how it was minted, never its name. Revoking a token you minted by hand on the account page changes no consent, even when it is named like a tool's. A tool's token mints no account token (since 2026-12-03): `POST /api/v2/account/tokens` without `ai_uses` answers `403` [`permission_error`](/api/errors/#permission_error), "No token was made: a token a tool got by signing you in cannot make account tokens. To get one, sign in again, or make one on the account page.", and nothing is made. To replace its token without losing the consent, a tool signs the person in again. Revoking a token that is already revoked withdraws nothing.

### Disconnecting a tool

```bash
curl -s -X DELETE "https://www.onlyworlds.com/api/v2/account/clients/atlas" \
  -H "Authorization: Bearer ow_a_…"
```

```json
{ "client_id": "atlas", "tokens_revoked": 2, "keys_revoked": 1 }
```

`200` with how many live tokens and world keys it revoked, `0` and `0` on a repeat: it is safe to send twice. `client_id` is the tool's `id` as [the registry](#registered-tools) lists it; one that cannot be an id (lowercase letters, digits and dashes, at most 40) is `422` [`invalid_request`](/api/errors/#invalid_request). The bearer may be one of the tool's own tokens, so a tool can disconnect itself: that token is revoked with the rest.

## AI assistants

An AI assistant's connector, such as claude.ai's or ChatGPT's, signs a person in to the [MCP server](/docs/development/mcp#sign-in-from-an-ai-assistant) through a door of its own, which follows MCP's sign-in: OAuth 2.1 with PKCE (`S256`), dynamic client registration (RFC 7591) and a resource indicator (RFC 8707). Its addresses are in the server's metadata, which the client reads on its own:

- `https://www.onlyworlds.com/.well-known/oauth-protected-resource/mcp`, which a `401` from `/mcp` names
- `https://www.onlyworlds.com/.well-known/oauth-authorization-server`: the sign-in page `/signin/authorize`, the token endpoint and the registration endpoint

**The scope.** A connector that names the MCP server as its `resource` asks for `scope=world:read world:write` (in either order), and the sign-in page then offers the person Read and write (with their account PIN) or Read only; `world:read` alone asks to read, and `world:write` alone is refused as an unknown scope is.

**Registering.** `POST /api/v2/auth/register` with `client_name`, `redirect_uris` and, if it likes, `client_uri`, as JSON and with no credential. The answer's `client_id` is random, never the name. A registered connector is a public client: no secret is issued and none is sent. It is not on [the list above](#registered-tools), and one unused for 90 days is removed. The Continue page shows the connector's own name and the host it returns the person to, at every sign-in (since 2026-11-30), and the token is named by that host. Registration is rate-limited per address.

**The token.** `POST /api/v2/auth/oauth/token`, form-encoded, answers in OAuth's own shape, not the API's error envelope. Two grants: `authorization_code` (`code`, `code_verifier`, `client_id`, `redirect_uri`) and `refresh_token` (`refresh_token`, `client_id`). It hands back a pair:

- an access token (`ow_a_…`, scope `world:read`, or `world:read world:write` when the person chose Read and write) that lasts an hour and that only `/mcp` accepts: every other route refuses it
- a refresh token (`ow_f_…`) that lasts 30 days and works once: each refresh hands back a new pair. A refresh token sent a second time is taken as stolen, and the whole chain and its access tokens are revoked

The access token is an account token like any other: the [account page](https://www.onlyworlds.com/account/) lists it, and Revoke and Disconnect there end the chain, also while the connector is renewing it, and end a sign-in it started and has not finished. A code exchange or a refresh that arrives during the press waits for it, then gets `invalid_grant` (since 2026-12-02).

**At the API's own exchange.** A client that registered itself and trades its code at [`POST /api/v2/auth/token`](#trading-the-code) gets [a token that reads worlds only](#a-token-that-reads-worlds-only) (since 2026-12-01).

## In the SDK

The [TypeScript SDK](/docs/development/typescript) has both halves, from 4.46.0, on a client with no key (`new OwV2Client()`):

- **`signInWithOnlyWorlds({ clientId, redirectUri, resume, storage, scope })`** mints `state` and the verifier, keeps them under the client id in `storage`, and sends the browser to the authorize page (`navigate: false` only returns the URL). `redirectUri` is the registered address as a string, never built from `location.origin`: a web tool's `https:` one, or, since 4.104.0, a native app's loopback address with the port it bound (`http://127.0.0.1:53682/<path>`) or its own scheme, exactly as registered. `localhost`, a loopback without its port, a query and a fragment are refused before anything is sent. A native app passes `navigate` a function that opens the system browser. `resume` is small JSON the tool wants back after the redirect, such as an open link or a pending join code. `scope: 'world:read'` (since 4.164.0) asks for a [read-only token](#a-read-only-token); any other value is refused before anything is kept or sent.
- **`completeSignIn({ clientId })`** runs on the return page. It checks `state` and that the page is the registered address, takes `code` and `state` out of the address bar, trades the code, and returns `{ token, tokenId, expiresAt, tokenType, account, scope, resume }` (`scope` since 4.164.0: `'world:read'` when the server granted a read-only token, else null; a read-only sign-in's `aiUses` is refused before the code is spent. `tokenId` since 4.73.0 and `expiresAt` since 4.94.0, each null from a server that does not send it; `expiresAt` is null too for a tool whose tokens have no lifetime). A refusal is an `OwSignInError` whose `reason` is `state_mismatch` (nothing was sent), `cancelled`, `invalid_grant`, `rate_limited`, `offline` or `failed`. Since 4.213.0, a return from Cancel (`error=access_denied` with this sign-in's `state`) is `cancelled`: nothing is sent, the sign-in ends, and the error's `resume` holds the tool's `resume`, so the tool can put the person back where they were; before, it was `state_mismatch` and the resume was lost. Another `error` on a return is `failed`, with that error as `code`. Since 4.214.0 every refusal carries `resume`, read from the pending sign-in: a return with another sign-in's `state` (Back to an older sign-in page, then Continue or Cancel) is still `state_mismatch` and leaves the pending sign-in in place, and its `resume` comes back with it. With no sign-in pending, `resume` is null. Since 4.215.0, `pendingSignInResume({ clientId, storage })` gives the pending sign-in's `resume` (or null) at once, synchronously, sending nothing and changing nothing, so a return page can route to where the person was before `completeSignIn` answers; it does not check `state`. Since 4.138.0, `completeSignIn({ clientId, aiUses, aiLifetimeMinutes })` also asks for [an AI door token](#an-ai-door-token), returned as `aiToken` (`{ token, tokenId, tokenType, audience, aiUses, expiresAt }`, null when none was asked). A list the SDK can see is wrong is a `TypeError` before anything is sent, and the sign-in stays pending.

`storage` is any object with `get`, `set` and `remove`. It defaults to the browser's `sessionStorage`; in Node it must be passed. The SDK keeps no token: the pending record is cleared once a return carries its state, on success and on refusal (since 4.104.2, a return with another state, such as a forged link to a custom scheme, leaves the sign-in pending), and the token is the tool's to store. A native app passes `completeSignIn` the address its loopback server or scheme handler received as `url`; the SDK then compares the scheme, host, port and path exactly and leaves the window's history alone. The [Python package](/docs/development/python) has no sign-in calls: a local tool signs in as a native app with a loopback return, registered for it.