Skip to main content

Sign in a CLI or TV with the device flow

DEVELOPER GUIDE

Let a device with no usable browser get tokens when a person approves a short code on another screen.

Who this guide is for

Developers who build a CLI, a TV app or a kiosk, and who have already registered a client in Claviger.

Why it matters

The person always approves on a verification page, because a device code can be phished. Your device must poll at the right pace, or Claviger slows it down.

What you will do, in one sentence

Turn on allowDeviceFlow, request a code, show it to the person, and poll the token endpoint until they approve.

Screens are captured from a seeded test system. Every name, address and number on the screens is invented. Prepared 15 November 2026.

1. Allow the device flow on the client​

The device flow is off by default. In the admin screen, open OpenID Connect, edit the client, and switch on Allow the device flow. In the API, set allowDeviceFlow to true.

A public client needs no secret. A confidential client authenticates with HTTP Basic at both endpoints.

A client without the flag is refused at the device endpoint with unauthorized_client.

2. Request a code​

The device calls the device authorization endpoint.

curl -X POST https://auth.example.org/oidc/device_authorization \
-d "client_id=CLIENT_ID" -d "scope=openid profile offline_access"

The answer holds these values:

FieldMeaning
device_codeThe secret the device uses to poll. Keep it on the device.
user_codeA code like BCDF-GHJK for the person to type.
verification_urihttps://auth.example.org/oidc/device.
verification_uri_completeThe same address with the code in it. Use it for a QR code.
expires_in600 seconds.
interval5 seconds between polls.

Show the user_code and verification_uri to the person, or draw a QR code from verification_uri_complete.

3. The person approves​

The person opens the page on a phone or computer and types the code, or follows the QR link. The code ignores case and spacing, so bcdf ghjk and BCDF-GHJK are the same.

They sign in on the hosted page with a password, passkey or authenticator app. If the browser already has signed-in accounts, they pick one on the account chooser.

The page shows the client name, the scopes and the account, with Allow and Cancel. Approval is always explicit, even for a first-party client. Claviger does not remember it, so every device authorization asks again.

4. Poll for tokens​

While the person approves, the device polls the token endpoint.

curl -X POST https://auth.example.org/oidc/oauth/token \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
-d "device_code=DEVICE_CODE" -d "client_id=CLIENT_ID"
AnswerWhat to do
authorization_pendingWait for the interval, then poll again.
slow_downPoll less often. The interval for that code grows by 5 seconds each time, up to 60.
access_deniedStop. The person chose Cancel, or the session ended.
expired_tokenStop. The code expired, or the tokens were already taken. Request a new code.
TokensAn access token and an ID token. You also get a refresh token with offline_access.

The first poll that sees an approval takes it. One device code gives one set of tokens.

The tokens are the ordinary ones. They carry the sid, acr, amr and auth_time of the person's real sign-in. Revoking that session ends them.

Polling too fast gets you slowed down

A poll faster than the interval returns slow_down. A confidential client that polls without valid credentials gets 401 invalid_client.

5. Limits​

  • The user_code is 8 consonants. It lives for 10 minutes.
  • Code entry on the verification page allows 30 submissions a minute for each IP address. After 10 wrong codes in 15 minutes, that IP address is refused, even for a right code. The answer is 429 with Retry-After.
  • /oidc/device_authorization allows 30 requests a minute for each IP address and 300 for each client.
  • If the person's session ends, the account is banned, or the account leaves the client's organization before your poll, the poll reads access_denied.
  • The device is not told when the person cancels. It finds out when it polls.

6. Quick reference card​

Device steps​

  1. POST /oidc/device_authorization with client_id and scope.
  2. Show user_code and verification_uri.
  3. Poll POST /oidc/oauth/token with the device_code grant every interval seconds.

Errors​

  1. authorization_pending: keep waiting.
  2. slow_down: wait longer.
  3. access_denied or expired_token: stop and start again.

The device flow is off for every client until you switch it on.