Exchange a sign-in code for a token

The last step of browser sign-in. The program calls this once it has received the authorization code on its loopback redirect, together with the PKCE verifier it generated when the sign-in started. On success it returns a person token the program keeps on this machine.

Last updated:

The last step of browser sign-in. The program calls this once it has received the authorization code on its loopback redirect, together with the PKCE verifier it generated when the sign-in started. On success it returns a person token the program keeps on this machine.

POST /api/v1/oauth/token

Authorization

No sign-in is needed.

Request body

FieldTypeRequiredDescription
grant_typeone of authorization_codeyes
codestringyes
code_verifierstringyes
redirect_uristringyes
client_idstringyes

Example request:

{
  "grant_type": "authorization_code",
  "code": "a1b2c3d4e5f6",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
  "redirect_uri": "http://127.0.0.1:51824/callback",
  "client_id": "dmmi"
}

Responses

200

The token.

FieldTypeRequiredDescription
access_tokenstringyes
token_typeone of Beareryes
scopeslist of stringyes
issued_atstring (date-time)yes
idle_expires_atstring (date-time)yes
hard_expires_atstring (date-time)yes
personobjectyes
person.namestringyes
person.emailstringyes

Example response:

{
  "access_token": "dmm_pt_7xK2mQ9pL4nR8sV1tY3wZ6bC0dF5gH2jK9mN4pQ7rS",
  "token_type": "Bearer",
  "scopes": [
    "workspaces:read",
    "environments:read",
    "pipelines:read",
    "pipelines:write",
    "runs:launch",
    "runs:read",
    "runs:cancel"
  ],
  "issued_at": "2026-10-12T10:00:00Z",
  "idle_expires_at": "2026-11-11T10:00:00Z",
  "hard_expires_at": "2027-04-10T10:00:00Z",
  "person": {
    "name": "Alex Morgan",
    "email": "alex.morgan@example.com"
  }
}

400

The sign-in request is no longer valid.

FieldTypeRequiredDescription
messagestringyes
statusintegeryes
errorCodestringyes
timestampstring (date-time)no
pathstringno
detailsobjectno

Example response:

{
  "message": "This sign-in request is no longer valid. Start the sign-in again.",
  "status": 400,
  "errorCode": "INVALID_GRANT"
}