Skip to content

Add s1 login --device for cross-device sign-in - #18

Merged
fatwang2 merged 2 commits into
masterfrom
claude/project-thread-fcpc2r
Nov 24, 2026
Merged

fatwang2 merged 2 commits into
masterfrom
claude/project-thread-fcpc2r

Conversation

@fatwang2

Copy link
Copy Markdown
Member

Requested by fatwang2 · project thread

Why

s1 login uses a loopback callback (127.0.0.1), so it cannot complete when the CLI runs on one machine (SSH, server, container) and the browser is on another.

What

  • s1 login --device: OAuth 2.0 Device Authorization Grant (RFC 8628). The CLI prints a URL and short code, the user approves on any device, the CLI polls /oauth/token (handles authorization_pending, slow_down, access_denied, expired_token) and saves tokens the same way as browser login.
  • Uses a pre-created public Clerk OAuth app m0ujmjk3mmIuuNjX with device grant enabled, because dynamically registered clients have the device grant stripped. Override with SEARCH1API_OAUTH_DEVICE_CLIENT_ID.
  • Plain s1 login in an SSH session suggests --device.
  • README + changelog (Unreleased, no version bump).

Testing

  • New mock-server tests in tests/device-login.test.mjs; npm test 50/50 pass.
  • Real end-to-end against production Clerk: ran s1 login --device in a cloud container, approved at accounts.s1.dev/device from another device, token validated via /usage, refresh token present and a forced refresh succeeded.

Generated by Claude Code

@fatwang2
fatwang2 merged commit c95ece2 into master Nov 24, 2026
2 checks passed
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.

2 participants