# Redeem Authorization Code

`POST /auth/oauth/token` · Core · Operator Sign-in

RFC 6749 token endpoint for the operator authorization code with PKCE. A form-encoded `grant_type=authorization_code` with `code`, `code_verifier`, `client_id` and `redirect_uri` returns `{ access_token, token_type, expires_in }`.

- **Single use:** a second redemption, or two racing, gets `invalid_grant`. So does a wrong verifier, client or redirect, a code older than 60 seconds, or a Console session that has ended. The answer never says which.
- **Lifetime:** the token lasts at most 15 minutes and never past its Console session. There is no refresh token: `refresh_token` is `unsupported_grant_type`.
- **What it can do:** it acts for the person in the session's organization and project, with their current roles. It can't reach any `/auth/*` path or change anything under `/me`, mint a credential, approve a pending change, decide a gate, grant an access request, or satisfy a step-up challenge.
- **Revocation:** it's checked against its client session on every request, so revoking that session, signing out the Console session or revoking all sessions ends it at once.
- **Browsers:** a browser call is answered only from the client's own configured origin, without credentials.

Errors use the RFC 6749 §5.2 body `{ error }` with `Cache-Control: no-store`.

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `grant_type` | enum ("authorization_code") | yes | Always `authorization_code`. `refresh_token` is refused with `unsupported_grant_type`. |
| `code` | string | yes | The code from the redirect. Single use, 60 seconds. Example: `"Qm9vb2t3b3JtLWV4YW1wbGUtY29kZS0zMi1ieXRlcy1sb25n"`. |
| `code_verifier` | string | yes | The PKCE verifier whose S256 is the request's `code_challenge` (RFC 7636). Example: `"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"`. |
| `client_id` | string | yes | The configured client's id. Example: `"playground"`. |
| `redirect_uri` | string | yes | Exactly the `redirect_uri` of the authorization request. Example: `"https://docs.example.com/api-playground/callback"`. |

## Responses

- **200**: RFC 6749 §5.1 success. No `refresh_token`.

| Field | Type | Required | Description |
|---|---|---|---|
| `access_token` | string | yes | The access token: a JWT for the person, narrowed to this client. Send it as `Authorization: Bearer`. It can't reach `/auth/*` or change `/me`, mint a credential, approve or decide anything, or satisfy step-up. |
| `token_type` | enum ("Bearer") | yes | Always `Bearer`. |
| `expires_in` | integer | yes | Seconds until the token expires: at most 900, and never past the Console session it came from. There is no refresh token; sign in again after it. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 404 | `K9O_NOT_FOUND` | This deployment configures no OAuth clients. |
| 429 | `K9O_RATE_LIMITED` | Too many token requests from this address; wait and try again. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/auth/oauth/token'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/auth/oauth/token', {
  method: 'POST',
});
const { data, meta } = await res.json();
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/redeem-authorization-code
