---
title: "The OAuth token endpoint for hosted MCP clients"
method: POST
path: "/api/v2/auth/oauth/token"
tags: ["Sign in"]
---

# The OAuth token endpoint for hosted MCP clients

`POST /api/v2/auth/oauth/token`

## Request

- Base URL: `https://www.onlyworlds.com`
- URL: `https://www.onlyworlds.com/api/v2/auth/oauth/token`
- Auth: none required

The OAuth 2.1 token endpoint for a hosted MCP client (RFC 6749, with resource
indicators as RFC 8707 has them), named by the authorization server metadata at
`/.well-known/oauth-authorization-server`. Form-encoded. `grant_type=
authorization_code` trades a sign-in code issued with
`resource=https://www.onlyworlds.com/mcp` (send the same `resource` here) for an
access token that lives an hour and works through the MCP server only, and a
refresh token; `grant_type=refresh_token` trades the refresh token for a new pair,
and the old one stops working. The grant reads (`world:read`), and writes too where
the person chose Read and write on the sign-in page (`world:read world:write`); the
answer's `scope` says which. The person revokes it, or stops its writes, on their
account page. No credential
is needed here: public clients, no secret.

## Request body `application/x-www-form-urlencoded`

- object
  - `grant_type` 'authorization_code' | 'refresh_token', required
  - `code` string: authorization_code: the code the return address carried, issued with resource naming the MCP server. Single use, valid for 60 seconds.
  - `code_verifier` string: authorization_code: the PKCE verifier whose S256 hash was the request's code_challenge.
  - `redirect_uri` string: authorization_code: as in the sign-in request, byte for byte.
  - `refresh_token` string: refresh_token: the `ow_f_` refresh token of the last answer.
  - `client_id` string, required: As in the sign-in request.
  - `resource` string: https://www.onlyworlds.com/mcp, required with authorization_code (RFC 8707); optional with refresh_token, and then the same.
  - `scope` string: Optional: world:read, or world:read world:write (in either order). It neither widens nor narrows the grant, which is what the person chose on the sign-in page: the answer's `scope` says what was granted.

## Response `200`

A token pair for the MCP server, in RFC 6749's shape (not this API's envelope). Cache-Control: no-store.

- object
  - `access_token` string, required: An `ow_a_` token for the MCP server at https://www.onlyworlds.com/mcp only (every other route refuses it, 401 wrong_audience). Send it there as `Authorization: Bearer`.
  - `token_type` 'Bearer', required
  - `expires_in` integer, required: Seconds the access token lives: 3600.
  - `refresh_token` string, required: An `ow_f_` refresh token: single use, 30 days. A refresh grant answers a new pair and the old one stops working; a used refresh token sent again ends the whole grant.
  - `scope` 'world:read' | 'world:read world:write', required: What the access token may do now: world:read, or world:read world:write while the person's choice of Read and write on the sign-in page stands.

## Other responses

- `400`: Refused, in RFC 6749's shape (`error`, `error_description`): invalid_request (a JSON body, a missing or repeated parameter), unsupported_grant_type, invalid_scope (a scope but world:read or world:read world:write), invalid_target (no resource, or another resource, RFC 8707), or invalid_grant (the code or refresh token cannot be used; a code is spent either way).
- `401`: invalid_client: the client_id is not registered.
- `429`: Too many sign-in attempts from this address (rate_limited, this API's envelope): the password sign-in's count. Retry after the Retry-After header's seconds. Or too many requests: over the request budget (code too_many_requests, type rate_limited): 300 requests a minute per key or account token, 60 a minute per address for a request with neither. Retry after the Retry-After header's seconds.
- `503`: The server is busy: every request slot stayed full for 10 s (code server_busy, type api_error). Retry after the Retry-After header's seconds.

## Changes

- **2026-11-28** `e45847b3f48f`: 2 info
  - added the optional property `error/limit` to the response with the `429` status
  - added the optional property `error/limit` to the response with the `503` status
- **2026-11-27** `91df78d103ee`: 1 breaking, 2 warning
  - the `scope` response property const value `world:read` was removed for the status `200`
  - added the new `world:read` enum value to the `scope` response property for the response status `200`
  - added the new `world:read world:write` enum value to the `scope` response property for the response status `200`
- **2026-11-26** `f921dd878e35`: 2 warning
  - added the new `write_not_granted` enum value to the `error/code` response property for the response status `429`
  - added the new `write_not_granted` enum value to the `error/code` response property for the response status `503`
- **2026-11-26** `7ef7860703bb`: 2 warning
  - added the new `narratives_only` enum value to the `error/code` response property for the response status `429`
  - added the new `narratives_only` enum value to the `error/code` response property for the response status `503`
- **2026-11-24** `e04f5b292402`: 1 info
  - the endpoint scheme security `ApiKey AND ApiPin` was removed from the API

[Operation history](https://skmtc.dev/onlyworlds/apis/onlyworlds-api/changes/api/v2/auth/oauth/token/post.md)

---

[API](https://skmtc.dev/onlyworlds/apis/onlyworlds-api.md) - [All operations](https://skmtc.dev/onlyworlds/apis/onlyworlds-api/llms.txt) - [OpenAPI document](https://skmtc.dev/onlyworlds/apis/onlyworlds-api/revisions/6c819f2e4bbd?raw)
