Skip to content

[Feature]: Support claude setup-token for managed Claude accounts #12002

Open

Description

@GSTJ

Problem or use case

My managed Claude account in Orca asks me to log in again pretty much every day. The terminal Claude Code login on the same subscription stays valid for weeks, so it's specifically Orca's stored copy that keeps dying. Same pain as #6234, which got marked no longer reproducible, but I still hit it daily (Orca 1.4.x on macOS, Claude Code 2.1.220).

#6234 already describes the mechanism: the refresh token is single-use and rotates, and when a rotation lands somewhere Orca can't read it back from, the stored copy is dead and I'm logging in again. Syncing rotated tokens back helps, but there's always another race to lose.

Proposed solution

Claude Code has a credential that sidesteps rotation completely: claude setup-token mints a token that lasts a year (needs a Pro, Max, Team or Enterprise plan) and is consumed through the CLAUDE_CODE_OAUTH_TOKEN env var. Docs: https://code.claude.com/docs/en/authentication.md

Let a managed Claude account be backed by one of these tokens. Paste it when adding the account, or a guided option that runs claude setup-token the same way the add flow runs claude auth login today. For sessions on that account, Orca sets the env var and skips the credential copy, refresh and read-back entirely.

The docs say the token "can only make model requests", so the usage endpoint may reject it. If it does, the usage bars can show the unavailable state these rows already have and the agent itself still runs fine. Email auto-detection also won't work for token accounts, so the row would need a user-typed label.

Alternatives or additional context

Activity

  1. changed the title [-][Feature]: Support long-lived Claude setup-token accounts (CLAUDE_CODE_OAUTH_TOKEN) so managed auth stops expiring daily[/-] [+][Feature]: Support `claude setup-token` for managed Claude accounts[/+] on Aug 1, 2026
  2. AmethystLiang commented on Aug 14, 2026

    @AmethystLiang
    Contributor

    Related symptom report: #13165 (Discord) wants this setup-token path as the preferred escape from the frequent re-auth loop also tracked in #9582.

  3. vesper8 commented on Aug 27, 2026

    @vesper8

    What is this absolute madness that this has been out for over a year and there's no way to revoke a token short of emailing Anthropic ?

  4. Kooooojun commented on Nov 2, 2026

    @Kooooojun
    Contributor

    +1 for this. I hit the same wall on macOS with Orca 1.4.245 (the 1.4.246 release notes don't mention token accounts either): I have an account where all I can get is a claude setup-token token, and orca account add only runs claude login, so I can't add it.

    I tested how Claude Code handles this (2026-11-02, Claude Code 2.1.316):

    • Account folder with no login: CLAUDE_CONFIG_DIR=<folder> claude auth status → loggedIn: false, authMethod: none.
    • Same folder with CLAUDE_CODE_OAUTH_TOKEN in the environment → loggedIn: true, authMethod: oauth_token.
    • Without the env var, passing the token through the settings env field also works: claude --settings <file containing {"env":{"CLAUDE_CODE_OAUTH_TOKEN":"..."}}> -p ... replies normally.

    So Orca doesn't need to touch the shell function. It could write the token into that account folder's settings (file mode 600).

    Suggested approach: open PR #37017 (Anthropic-compatible endpoint accounts) already merges ANTHROPIC_AUTH_TOKEN and friends into the account folder's settings.json. A setup-token account could use the same path, just writing CLAUDE_CODE_OAUTH_TOKEN instead.

    Things to keep in mind: this token only has the user:inference scope, so

    • /api/oauth/usage can't report quota (reading the anthropic-ratelimit-unified-5h-utilization / -7d-utilization headers on a messages response could work instead),
    • there is no email on the account,
    • Remote Control is not available.

    My current workaround: a PATH wrapper that exports CLAUDE_CODE_OAUTH_TOKEN when the account folder has a token file, so it applies when the Orca shell function calls command claude.

  5. siakun commented on Nov 18, 2026

    @siakun

    +1. I think this is more than a convenience, and the design can reuse almost everything Orca already has, including the route #37017 takes for endpoint accounts. Anything marked "verified" below I tested on Windows 11 with Orca 1.4.262 and Claude Code 2.1.327.

    Why it matters

    claude setup-token is Anthropic's documented sign-in for machines where a browser login doesn't fit, and Claude Code ranks CLAUDE_CODE_OAUTH_TOKEN above /login. People who choose it already run Orca with the variable exported, and Orca gets their state wrong today: the usage panel labels a subscription sign-in "API key billing", and selecting a managed account no longer decides which account requests go to (#44112). So the gap isn't only a missing option. Orca misreports a sign-in that Claude Code supports.

    A token account also removes the cause of the re-auth loop discussed in #6234, #9582 and #13165. That loop comes from single-use refresh tokens rotating where Orca can't read them back. A setup-token has no refresh token, so there is nothing to rotate and nothing for Orca to sync.

    My own reason is the one-year lifetime. I use Claude on several machines, and giving each one the token as an environment variable is much simpler than a browser login on every machine.

    Proposed design: a token account is an account folder with the token in its settings

    Orca already models an account as a CLAUDE_CONFIG_DIR folder, and selection, the pointer file, the terminal shell function and chat launches all work by switching that folder. A token account can be the same folder with the token in its settings.json:

    { "env": { "CLAUDE_CODE_OAUTH_TOKEN": "<token>" } }
    • Why the settings file works: Claude Code reads env from that file itself, so the token applies however claude is launched. Verified: in an Orca terminal with a different, valid token exported, an invalid placeholder in this file made the first request fail with 401 Invalid bearer token, so the folder's value beats the shell's. The docs agree: settings env overrides the shell, and this variable is ignored only in project and local settings. Chat launches strip auth variables before starting Claude, but they would still pick the token up from the file (from the docs and Orca's code; I only tested terminals).
    • Same shape as feat(accounts): add Anthropic-compatible endpoint accounts for Claude #37017: that PR writes ANTHROPIC_AUTH_TOKEN into the account folder's settings.json, stores it in plain text with owner-only permissions, and skips usage polling. A token account needs the same steps with CLAUDE_CODE_OAUTH_TOKEN, and no change to selection, the pointer file or the shell function.
    • Adding an account: paste a token, or run claude setup-token in the add-account terminal the way claude auth login runs today. The label is user-typed, because the token can't read the profile, so there is no email.
    • No refresh: token accounts skip the credential copy, refresh and read-back entirely.
    • Usage: skip /api/oauth/usage for token accounts. Verified: it returns 403 oauth_scope_insufficient (user:profile) for a setup-token. Orca already has the right behavior for this in the "Claude usage polling: off" path (claudeUsageWithoutOAuth), which shows only the live status line rate_limits and keeps them until their windows reset. Token accounts can take that path automatically; today the default polling-on path replaces live values with the failing poll after 5 minutes, so the bar flickers ([Bug]: Orca's Claude account and usage state is wrong when Claude Code signs in with CLAUDE_CODE_OAUTH_TOKEN #44112). Chats can add rate_limit_event ([Feature] Keep and expose Claude's per-session rate_limit_event (5h/7d utilization) instead of dropping it #35497). Only the 5-hour and weekly (all models) windows exist for this sign-in. Claude Code's own /usage says "Other limits and usage credits aren't shown for this sign-in", so the Fable row stays hidden.
    • Expiry: the token lasts a year and can't be inspected, so Orca can record when it was added and remind the user before the year is up.

    I can test a build or PR on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions