Files
magpie/docs
yetone 47ec2a969f provider: a Sub2API Claude account comes in by its email_address, with its account and organization (#1975)
KKKKKKKEM's Sub2API export of a Claude OAuth account was refused, "the
file doesn't say which Claude account this is": sub2apiEntry read only
credentials.email, and Sub2API keeps a Claude account's email under
Anthropic's own name, email_address. Its CreateAccountModal stores the
token Sub2API was given whole as credentials ({...tokenInfo}: access_token,
refresh_token, expires_at, scope, org_uuid, account_uuid, email_address)
and the uuids and email again in extra (useAccountOAuth's
buildExtraInfo); read in Wei-Shaw/sub2api's source.

The siblings in the same export now come in too:
- email_address in credentials or extra (and extra.email);
- scope, OAuth's space-separated string, as Claude Code's scopes instead
  of the four magpie assumes when a file says none (importScopes, shared
  with loginEntry's scopes);
- account_uuid and org_uuid as the oauthAccount's accountUuid and
  organizationUuid, so sameLogin tells two Team seats of one email apart
  as it does for a sign-in in magpie, and the session identity has its
  account id.
A ChatGPT Sub2API account already read email, id_token and
chatgpt_account_id, Sub2API's names for them (useOpenAIOAuth's
buildCredentials). The Google importer reads no Sub2API shape, and CC
Switch's import is of API-key providers, with no account email.
docs/subsystems/providers-accounts.md says which fields are read.

Run:
- TestImportSub2APIClaudeAccounts imports the reporter's file as filed
  (tokens put back) and a Sub2API-shaped export with two Team seats of one
  email. Old code: "got #1:failed,#2:failed,#3:failed … the file doesn't
  say which Claude account this is". With only the reporter's one-line
  fix (credentials email_address): "#3:failed", the seat whose email is
  only in extra. With org_uuid not kept: "sk-ant-ort01-a kept as
  team@example.com org \"\"". With scope not read: the seat kept the four
  default scopes.
- gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows
  go vet on internal/provider: clean.
- go test -tags nogui ./internal/provider -count=1: ok (130s).

Not tried: a real Sub2API export or account; `magpie accounts import`
itself, which on macOS writes the active Claude sign-in to the Keychain.
It calls the same ImportLogins.
2026-10-13 18:16:03 +08:00
..