Skip to content

Device Authorization

The device authorization flow allows the CLI to authenticate users who may not be able to paste credentials directly. It follows RFC 8628.

  1. CLI requests a device code
  2. CLI opens browser and displays a human-readable code
  3. User signs in and enters the code in the browser
  4. CLI polls until authorization completes

Request a new device code. No authentication required.

No body required.

{
"device_code": "a1b2c3d4e5f6...40chars",
"user_code": "ABCD-1234",
"verification_uri": "https://app.skillett.dev/device",
"expires_in": 900,
"interval": 5
}
FieldTypeDescription
device_codestring40-character hex code for polling
user_codestringHuman-readable code to display (format: XXXX-XXXX)
verification_uristringURL where user enters the code
expires_innumberSeconds until the code expires (900 = 15 min)
intervalnumberMinimum polling interval in seconds
Terminal window
$ curl -X POST https://api.skillett.dev/auth/device/code

Called by the browser after the user enters their code. Requires user authentication (session/JWT from the dashboard).

{
"user_code": "ABCD-1234"
}
{
"status": "authorized"
}
CodeErrorDescription
400bad_requestInvalid or expired user code
401unauthorizedUser not signed in

Called by the CLI to poll for authorization completion. No authentication required.

{
"device_code": "a1b2c3d4e5f6...40chars"
}
{
"status": "pending",
"error": "authorization_pending"
}
{
"status": "complete",
"user": {
"email": "david@example.com",
"display_name": "David"
},
"api_keys_url": "https://app.skillett.dev/dashboard/api-keys"
}
{
"status": "expired",
"error": "expired_token"
}
CodeErrorDescription
400bad_requestInvalid device code
400expired_tokenDevice code has expired (15 min TTL)
400already_usedDevice code has already been consumed
404not_foundDevice code not found
Terminal window
$ curl -X POST \
-H "Content-Type: application/json" \
-d '{"device_code":"a1b2c3d4e5f6..."}' \
https://api.skillett.dev/auth/device/token