Sign in a CLI or TV with the device flow
Let a device with no usable browser get tokens when a person approves a short code on another screen.
Developers who build a CLI, a TV app or a kiosk, and who have already registered a client in Claviger.
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:
| Field | Meaning |
|---|---|
device_code | The secret the device uses to poll. Keep it on the device. |
user_code | A code like BCDF-GHJK for the person to type. |
verification_uri | https://auth.example.org/oidc/device. |
verification_uri_complete | The same address with the code in it. Use it for a QR code. |
expires_in | 600 seconds. |
interval | 5 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"
| Answer | What to do |
|---|---|
authorization_pending | Wait for the interval, then poll again. |
slow_down | Poll less often. The interval for that code grows by 5 seconds each time, up to 60. |
access_denied | Stop. The person chose Cancel, or the session ended. |
expired_token | Stop. The code expired, or the tokens were already taken. Request a new code. |
| Tokens | An 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.
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_codeis 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
429withRetry-After. /oidc/device_authorizationallows 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
POST /oidc/device_authorizationwithclient_idandscope.- Show
user_codeandverification_uri. - Poll
POST /oidc/oauth/tokenwith thedevice_codegrant everyintervalseconds.
Errors
authorization_pending: keep waiting.slow_down: wait longer.access_deniedorexpired_token: stop and start again.
The device flow is off for every client until you switch it on.