ChartnautDocs

Poll a sign-in

POST/auth/token

Checks whether the person has approved a sign-in, and returns the new API key once they have. It is the second half of the sign-in that Start a sign-in begins.

Scope

Heavy call

Long poll

CLI

None, no key

No

No

chartnaut login

Guidance

  • Poll every interval seconds from Start a sign-in. Until the person decides, the answer is 400 in the usual error envelope: authorization_pending means keep polling, and slow_down means this poll came less than about 2.5 seconds after the last, so wait longer (the CLI adds 2 seconds each time).

  • Stop on access_denied, which means the person refused, and on expired_token, which means the sign-in expired, was already used or never existed. Start again only after expired_token.

  • The key in the 200 answer is shown this once. Store it before you do anything else, somewhere only the person can read.

  • The new key has every scope and expires at expires_at. That can be sooner than the expires_in_days you asked for, since the person approving can shorten it. After it, every call answers 401 unauthorized with API token expired., and the person signs in again. It is listed with the person's other keys on the Developers page, where they can revoke it.

  • A sign-in is used up once it hands over a key: a later poll answers expired_token.

  • An account can hold 20 keys. At that limit the approval cannot create one, and the poll answers 500 internal. Revoke an old key on the Developers page and sign in again.

  • The CLI keeps polling through 429 and 5xx answers until expires_in runs out, then tells the person to sign in again.

Request body

Up to 4 KB.

Field

Type

Required

Description

device_code

string

Yes

The device_code from Start a sign-in

Response

200 once approved, with Cache-Control: no-store:

Field

Type

Description

token

string

The new key, cn_live_ and 64 hex characters. It is shown this once

name

string

The key's name: CLI on followed by the client_name

expires_at

string

When the key stops working, RFC 3339

expires_in_days

integer

The key's life in days: 7, 30 or 90

Status codes

Status

Code

Meaning

200

-

Approved. The body has the new key

400

authorization_pending

Not approved yet. Keep polling

400

slow_down

Polling too fast. Wait longer

400

access_denied

The person refused. Stop

400

expired_token

Expired, already used or unknown. Start again

400

invalid_request

The body is not JSON or has no device_code

503

busy

Browser sign-in is unavailable

500

internal

The key could not be created, for example because the account already has 20 keys