Skip to content

Add device login and use one OAuth client per environment - #5

Merged
frostevent merged 5 commits into
mainfrom
jeremie/device-login
Nov 10, 2026
Merged

frostevent merged 5 commits into
mainfrom
jeremie/device-login

Conversation

@frostevent

@frostevent frostevent commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Let a user sign in to Proof from a machine that cannot receive the loopback redirect (SSH, remote machine, sandbox), with the OAuth 2.0 Device Authorization Grant (RFC 8628).

Approach

  • x401-cli login --device (also accepted by token, which signs in when there is no login). The loopback authorization code flow stays the default.

  • Uses the oauth4webapi device functions with the same public client as the loopback login. The CLI reads device_authorization_endpoint from the server metadata, then polls the token endpoint every interval seconds (plus 5 s on slow_down) until expires_in or --timeout.

  • It opens the browser at verification_uri_complete when it can. Either way it prints the URL and the code on stderr:

    Opening Proof in your browser to sign in.
    If nothing opened, or to sign in from another device, go to:
    
    https://api.proof.com/oauth/v2/device
    
    and enter this code:
    
    WDJB-MJHT
    

    Without a browser (--no-browser, no display, or a failed open), the first two lines become To sign in, go to:. This block is the one exception to the one-line-per-event stderr contract (CLAUDE.md rule 3).

  • Tokens are stored like the loopback login. access_denied exits cancelled, expired_token exits expired, other errors exit unauthorized.

  • The browser opener now waits for open / xdg-open / start and reports a failure, and treats Linux without a display as "cannot open". The loopback login prints its URL instead of failing when the browser does not open.

  • The CLI now has one public client per environment: caynxy5ad for sandbox and caynqpyde for production, instead of cag5xwbbz for both. status shows the client_id of each login (in --json, client_id moved from the top level into each logins entry).

Server side: notarize-api #23195 (device grant) and notarize-web #26685 (approval page).

Testing

  • yarn check-all (38 tests, including production signs in with the production client): device happy path, browser opened and not opened, slow_down, denied, expired, timeout, invalid_client, no device endpoint
  • End to end against a local Proof API: login with and without a browser, a later call with the stored token, refresh, logout

🤖 Generated with Claude Code

Jeremie Charrier and others added 5 commits November 6, 2026 13:22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sandbox signs in with caynxy5ad and production with caynqpyde. status
reports the client_id of each login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frostevent frostevent changed the title Add device authorization grant login (login --device) Add device login and use one OAuth client per environment Nov 10, 2026
@frostevent
frostevent merged commit 2771933 into main Nov 10, 2026
9 checks passed
@frostevent
frostevent deleted the jeremie/device-login branch November 10, 2026 20:02
@frostevent frostevent mentioned this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant