Guides
Agents and CLIs
Sign a person in to an agent or a command-line tool with the device flow, on another device.
An agent or a CLI that can't open a browser itself signs a person in with the device flow (RFC 8628): it shows a short code, and the person confirms it on their phone or laptop. Make it an app of type agent (Make an app): it's public, has no secret and no redirect URIs.
The flow
- The agent asks for a code.
POST /device/authon the issuer, with itsclient_id, thescopeit needs (offline_accessfor a refresh token) and, for an API, itsresource. The answer has adevice_code, auser_codesuch asBCDF-GHJK(8 letters from 20 consonants, so none reads as another), averification_uriand averification_uri_completewith the code in it,expires_in(10 minutes) andinterval(5 seconds). - The person confirms it. The agent shows the code and the link, or a QR code of
verification_uri_complete. On the brand's page the person signs in, then sees the code large, the agent's name, each scope it asks for in your API's words, and the longest it can act for them, and goes on only if their device shows that code. - The agent polls for its tokens.
POST /tokenwithgrant_type=urn:ietf:params:oauth:grant-type:device_code, itsdevice_codeandclient_id, no more often thaninterval: polling sooner answersslow_down. Until the person decides it answersauthorization_pending; then the tokens, oraccess_deniedif they cancelled, orexpired_tokenafter 10 minutes.
The agent's tokens
Its tokens carry act: { type: 'agent', client_id }, so your API can tell that an agent is acting for the person, and audit rows name both. Its refresh token lives 30 days from the sign-in and isn't extended by use: after that, the person confirms a new code. Ending the person's sessions (a password reset, the tenant ending them) ends the agent's grant too.