Skip to content

auth: import a captured refresh token (#55) - #60

Open
ironlukas1 wants to merge 2 commits into
quantcli:mainfrom
ironlukas1:feat/auth-import
Open

auth: import a captured refresh token (#55)#60
ironlukas1 wants to merge 2 commits into
quantcli:mainfrom
ironlukas1:feat/auth-import

Conversation

@ironlukas1

Copy link
Copy Markdown

Why

I hit #55 from the reporter's side: my Liftoff account was created with Google Sign-In, so I have no password and auth login is a dead end. LIFTOFF_REFRESH_TOKEN only helps once you already hold a token, and per the maintainer's note on #55 the only way a Google account can get one is to read it off the phone app with mitmproxy/Proxyman.

The gap this PR closes: once you have captured that token, there's no CLI affordance for storing it. Today it means hand-writing ~/.config/liftoff-export/auth.json with a correctly formatted expires_at. internal/auth.SaveFromCapture was already written for exactly this case but nothing referenced it.

What

New auth import subcommand:

Invocation Behaviour
auth import --refresh-token "$RT" (or token on stdin) Exchanges the token via user.refreshToken — verifies it and fills in the real expiry — then saves to the normal token file.
auth import --no-verify --refresh-token … --access-token … --expires-at … Writes the captured triple with no network call. Wires up the existing auth.SaveFromCapture.

Everything else is unchanged.

Contract / scope notes

  • Additive to the auth surface — auth login / logout / refresh / status still behave exactly as before (CONTRACT §5).
  • auth import --help makes no network call (§7); verified manually and the existing hermeticity posture is untouched.
  • Does not implement native Google Sign-In. That still needs the user.signIn request capture the maintainer asked for on Google Sign-In accounts have no way to authenticate via auth login #55. This just gives Google-only accounts a supported path for the proxy-captured token instead of a hand-edited JSON file, so I've marked it Refs #55, not Closes.

Tests

cmd/auth_test.go: --no-verify round-trips the captured tokens to disk with no network, --no-verify without its companion flags is a clean error, and an empty refresh token is a clean error. go vet ./..., go test ./..., and the TestContractFormats compat suite all pass locally.

Try it

go build -o /tmp/liftoff-export .
/tmp/liftoff-export auth import --no-verify \
  --refresh-token rt --access-token at --expires-at 2099-01-02T15:04:05Z

🤖 Generated with Claude Code

https://claude.ai/code/session_015zkLbCGpBdq4SoCitH1dZZ

Google Sign-In accounts have no password, so `auth login` is unusable for
them, and `LIFTOFF_REFRESH_TOKEN` only helps once you already hold a
token. The one way such an account can get a refresh token is to read it
off the phone app with an HTTPS proxy — but there was no CLI affordance
for putting it anywhere, so it meant hand-writing auth.json with a
correctly formatted `expires_at`.

Add `auth import`:

- `--refresh-token` (or stdin): exchanges the token via user.refreshToken,
  which both verifies it and fills in the expiry, then saves it to the
  usual token file.
- `--no-verify` with `--access-token` + `--expires-at`: writes the
  captured triple with no network call. This wires up the existing but
  previously unreferenced auth.SaveFromCapture.

Additive to the auth surface (CONTRACT §5); `--help` stays hermetic
(§7). Docs updated in README and `prime`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015zkLbCGpBdq4SoCitH1dZZ
Copilot AI lite review requested due to automatic review settings August 28, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new liftoff-export auth import subcommand to let users persist a proxy-captured Liftoff refresh token to the standard on-disk auth store, primarily to support Google Sign-In accounts that cannot use auth login (Refs #55).

Changes:

  • Introduces auth import with a default “verify + exchange + save” path and a --no-verify offline write path.
  • Documents the new flow and Google Sign-In limitations in CLI docs/help text.
  • Adds command-level tests to ensure --no-verify writes tokens to disk and validates required flags.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
README.md Documents auth import usage and the Google Sign-In proxy-capture workflow.
cmd/prime.go Updates “GOTCHAS” to mention persisting a captured token via auth import.
cmd/auth.go Adds the auth import Cobra subcommand and its flag handling.
cmd/auth_test.go Adds tests covering auth import --no-verify success and error cases.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/auth.go
Comment thread cmd/auth.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

3 participants