CLI Authentication
Two flows end up issuing a token the CLI can use:- For Humans —
bkey auth loginuses RFC 8628 device authorization: display a code, scan a QR on your phone, approve with biometrics. - For Agents —
bkey auth setup-agentmints OAuthclient_credentialsso a headless agent or CI job can authenticate without a human in the loop on every request.
Agents still need a human to create them. You have tobkey auth loginonce as a human before you can runsetup-agent— the new agent is gated on a biometric approval from your phone before the credentials are issued.
For Humans
Interactive login from any terminal. Uses the device authorization flow so you can log in on a machine that has no browser (SSH, CI debug shell, IoT device, etc.) by approving on your phone.Usage
- Open the BKey app (or follow the URL on a phone browser).
- Confirm the user code matches.
- Approve with facial biometrics.
~/.bkey/profiles.json (default identifier: default). Subsequent bkey … commands use it automatically. Multiple profiles can coexist — pass bkey auth login --profile work to save under a different name, then select with bkey <cmd> --profile work or BKEY_PROFILE=work bkey <cmd>.
Flow at the protocol level
- Client calls
POST /oauth/device_authorizationand receivesdevice_code,user_code,verification_uri. - User visits the URL on their phone and enters the code, or scans the QR.
- User approves with facial biometrics.
- Client polls
POST /oauth/tokenwithgrant_type=urn:ietf:params:oauth:grant-type:device_codeuntil it gets an access token.
- CLI tools (
bkey auth login) - SSH sessions and CI debug shells
- IoT devices with no browser
For Agents
Agents authenticate with the OAuth 2.1 client credentials grant — oneclient_id + client_secret per agent, no phone roundtrip on every call. The credentials are minted by a human running bkey auth setup-agent after they’re logged in.
Minting agent credentials
- Pushes an approval prompt to the logged-in human’s phone if the requested scopes are elevated (biometric approval). Baseline-scope agents (e.g.
approve:actiononly) may be created without a phone prompt — all subsequentbkey approvecalls still go through CIBA at the phone. - On approval, BKey returns the agent’s
client_id+client_secret. --savestores them as an agent profile in~/.bkey/profiles.json. The profile identifier is slugified from--name(e.g."My Deploy Bot"→my-deploy-bot); override explicitly with--profile <slug>. Collisions error unless--overwriteis passed.--jsonprints the creds to stdout instead (for CI secret setup, env vars, etc.).
Running as an agent
Since 0.3.0 agent mode is opt-in — a saved agent profile no longer silently overrides your user session. Select agent mode explicitly:In code (Python / TypeScript)
Default scopes
bkey auth setup-agent includes a sensible default scope set (vault:access, vault:store, signing:create, signing:read, identity:read, approve:action, approve:payment, payment:authorize, payment:address, payment:limits). Override with --scopes <comma-separated> to tighten or expand.
Use cases:
- Headless agents (e.g. a cron job that calls paid APIs)
- Server-to-server communication
- CI pipelines making authenticated calls
- MCP servers verifying CIBA approval tokens
What agents can’t do on their own
Agent tokens fromclient_credentials don’t grant per-action authority by themselves. For anything sensitive (payments, vault access, deploys), the agent must still initiate a CIBA approval — the human gets a push and approves with biometrics, the agent gets a short-lived, scope-bound token proving that consent. See the CIBA guide for the one-line approve() pattern.
See also
- Client Credentials — raw protocol details for the agent grant
- CIBA — per-action biometric approval (what agents use once they have a base token)
- Authentication overview — all three grant types at a glance
- CLI reference —
bkey auth,bkey approve,bkey proxy,bkey wrap, etc.