LuvLetter on Discord runs magpie in Docker (`magpie web`). ChatGPT sent
the browser back to http://localhost:1455/auth/callback?code=…&state=…,
which the browser couldn't reach, and the address went into "Import
from a file instead…" rather than the sign-in's Callback URL field.
Opening that box canceled the waiting sign-in, and the import read the
address as a refresh token, sent it to ChatGPT, and said "ChatGPT
didn't take the refresh token — it has been used since…".
- The Import box keeps a sign-in that takes a pasted address waiting
behind it (signing.behind in app.js); Done, Cancel or a new sign-in
end it. One that takes no address is canceled as before.
- POST /api/signin/import first takes out each text that is a browser
sign-in's end (an http(s) address with code or error and a state, or
Claude's code#state) and finishes the sign-in whose state it carries
through SubmitSignInCallback, as the Callback URL field does
(provider.PastedSignIns). The rest is imported as before.
- An address for no waiting sign-in fails with a reason that says where
such an address goes, and is never sent to a vendor.
- ImportLogins (Codex/Claude) and the Google import's line parsers
refuse a line with :// as "not a refresh token": the CLI import too.
Siblings: matching is by the OAuth state of every waiting sign-in
(signIns.m), so ChatGPT, ChatGPT API, Gemini/Antigravity, plugin
sign-ins and Claude (address or code#state) are all covered.
Run:
- go test -tags nogui ./internal/provider (-skip
TestUnreadLoginsWriteErrorsKeepCredentials, #3632 crashes the package
on main), ./internal/usage ./internal/usageapi ./internal/probelog
./internal/gui ./internal/cli: ok, at e111e08aa plus this change.
- New TestImportBoxFinishesThePastedSignIn (fake token endpoint, counts
trades: another sign-in's state 0, the address 1, again still 1),
TestImportBoxFinishesAPastedClaudeCode, TestImportTellsAddressesFromAccounts.
- signin-paste-import.test.cjs, en and zh, Chromium and WebKit: 6/6;
with the other sign-in/login/import GUI files and i18n-keys.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- Reproduced in a sandbox `magpie web`: the ChatGPT sign-in shows its
Callback URL field, and opening the Import box canceled it.
Broken by hand: looksLikeAddress returning false makes
TestImportTellsAddressesFromAccounts fail with the user's exact message;
signInByState returning nil fails the two finish tests; dropping
signing.behind fails the GUI test ("the sign-in waits behind the box,
not canceled").
Not tried: a real ChatGPT code exchange (tests never reach OpenAI); the
full go test ./... (other sessions' suites were on this machine).