Skip to main content
POST/auth/oauth/token

Redeem Authorization Code

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
grant_type *"authorization_code"

Always authorization_code. refresh_token is refused with unsupported_grant_type.

code *string

The code from the redirect.

Single use, 60 seconds.

Example: "Qm9vb2t3b3JtLWV4YW1wbGUtY29kZS0zMi1ieXRlcy1sb25n"
code_verifier *string

The PKCE verifier whose S256 is the request's code_challenge (RFC 7636).

Example: "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
client_id *string

The configured client's id.

Example: "playground"
redirect_uri *string

Exactly the redirect_uri of the authorization request.

Example: "https://docs.example.com/api-playground/callback"
Responses
HTTPK9O CodeDescription
200RFC 6749 §5.1 success. No `refresh_token`.
404K9O_NOT_FOUNDThis deployment configures no OAuth clients.
429K9O_RATE_LIMITEDToo many token requests from this address; wait and try again.
Response body (200)
access_token *string

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 *"Bearer"

Always Bearer.

expires_in *integer

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.

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

Showing example in cURL

Request example
{
  "grant_type": "authorization_code",
  "code": "Qm9vb2t3b3JtLWV4YW1wbGUtY29kZS0zMi1ieXRlcy1sb25n",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
  "client_id": "playground",
  "redirect_uri": "https://docs.example.com/api-playground/callback"
}
Response example (200)
{
  "access_token": "string",
  "token_type": "Bearer",
  "expires_in": 0
}

More in Operator Sign-in