Skip to content

feat: oauth support for Claude Pro/Max subscription plans #1925

Description

@cjfit

Problem Statement

Currently Claude Code users who subscribe to the Pro or Max plans are unable to use OpenShell with their Anthropic paid plans because OpenShell's Claude Code runner only supports API key auth. A workaround that greatly jeopardizes security is possible that is also tedious: Authenticating using the OAuth flow inside the sandbox's Claude instance.

As an enterprise or individual subscriber to a Claude Pro or Max plan, I should be able to securely, natively use my plan with OpenShell for Oauth2 grants.

Proposed Design

I propose creating a native new provider type anthropic-oauth that enables the behavior I'm seeking - running Claude Code on a subscription instead of metered API key. I'd create a new inference protocol that sets the proper headers, use the same Oauth token pattern as Vertex where the token is acquired, stored, and refreshed in the trust boundary OUTSIDE the sandbox, and then injected at the egress proxy boundary.

The Openshell CLI, prior to spawning a sandbox, would read the local filesystem of the running machine for Claude Code subscription creds. I'd support both macOS and Linux by retrieving the key from the keychain store and falling back to .credentials.json (old Claude Code on macOS, Linux uses this primitive).

Since the headers need to be updated to support the way Anthropic subscription plans implement Oauth, we'd rebuild the supervisor image to make some small header changes.

Alternatives Considered

Considered building a more custom, less OOTB implementation letting Openshell run arbitrary pre-run workflows (shell scripts, a la how Atlantis/Dockerfiles can be configured). I ultimately deemed this not necessary as having secure persistent Claude Oauth credentials available to the runtime is my only objective at this time. I also noticed native primitives already existed for this model (good example is the Vertex ADC pattern), so decided to use this route instead.

Agent Investigation

  • New provider type anthropic-oauth (alias claude-plan): lets a sandbox run Claude Code on an Anthropic
  • Pro/Max subscription instead of a metered API key, reusing the Vertex --from-gcloud-adc pattern.
  • Core invariant: the OAuth token is acquired, stored, and refreshed entirely outside the sandbox and
    injected only at the egress proxy boundary — never in the sandbox env, filesystem, or logs.
  • New inference profile (openshell-core/inference.rs): AuthHeader::Bearer + mandatory default headers
    anthropic-version: 2023-06-01 and anthropic-beta: oauth-2025-04-20 (subscription tokens require the beta
    flag; API keys don't). Auth/headers derive purely from provider_type, so a new behavior needs a new type.
  • Non-injectable credential: ANTHROPIC_OAUTH_TOKEN is marked proxy-only
    (is_non_injectable_provider_credential), so it rides the route bundle into the supervisor but is never
    exported into sandbox env — same mechanism as Vertex's GOOGLE_SERVICE_ACCOUNT_KEY.
  • Host-side harvest (--from-claude-login): CLI reads the local Claude Code login (macOS Keychain Claude
    Code-credentials, falling back to ~/.claude/.credentials.json), extracts accessToken/refreshToken/expiresAt,
    and stores the access token as the proxy-only credential.
  • Gateway-side refresh reused: configures the existing Oauth2RefreshToken strategy with Anthropic's public
    client_id (no client secret) and token_url: https://console.anthropic.com/v1/oauth/token; the background
    worker refreshes ahead of expiry and persists the rotated refresh token.
  • Live propagation, no restart: refreshed tokens reach running sandboxes via the revisioned on-demand
    GetSandboxProviderEnvironment fetch — the route bundle updates in place.
  • Router beta-merge (openshell-router/backend.rs): merges the mandatory anthropic-beta flag with any
    client-sent anthropic-beta into one header (case-insensitive dedupe), so a sandbox client can't drop the
    OAuth flag and we never emit a duplicate.
  • Supervisor applies the boundary headers (not the gateway), so the supervisor ghcr image must be rebuilt —
    a stale supervisor silently drops the headers and Anthropic returns 400.
  • Validated end-to-end on macOS: token absent from sandbox env/fs, Bearer injected at the boundary, live
    200/pong completion (model must be claude-sonnet-4-6, since CLI 2.1.156 sends an effort param that 4-5
    rejects). Linux uses the same OS-agnostic file reader — expected to work, flagged as not-yet-tested.

Checklist

  • I've reviewed existing issues and the architecture docs
  • This is a design proposal, not a "please build this" request

Activity

  1. changed the title [-]Add Oauth support for Claude Pro/Max subscription plans[/-] [+]feat: Add Oauth support for Claude Pro/Max subscription plans[/+] on Jun 16, 2026
  2. changed the title [-]feat: Add Oauth support for Claude Pro/Max subscription plans[/-] [+]feat: oauth support for Claude Pro/Max subscription plans[/+] on Jun 16, 2026
  3. cjfit commented on Jun 22, 2026

    @cjfit
    Author

    bump :)

  4. zanetworker commented on Jun 23, 2026

    @zanetworker
    Contributor

    I have hit the same issue.

  5. antolarv commented on Jul 3, 2026

    @antolarv

    Same issue

  6. TaylorMutch commented on Jul 11, 2026

    @TaylorMutch
    Collaborator

    📋 triage-agent

    Triage Assessment

    Classification: needs-investigation

    Summary

    This is a valid, repeatedly requested capability and remains unimplemented. It is a focused successor to the user outcome in #620 and a concrete implementation direction under the broader Providers v2 work in #896, not a duplicate that should be closed. Current provider refresh and live-update infrastructure makes the proposal substantially more feasible than earlier attempts.

    Demand supports high priority: two additional users explicitly report the same issue here, the issue and bump have multiple reactions, and #620 contains further workaround reports. Claude Code with a Pro or Max subscription is a canonical user workflow rather than an isolated integration request.

    Investigation

    Current main already has gateway-managed oauth2_refresh_token rotation, rotated refresh-token persistence, provider profiles, and live provider-environment refresh. However, Anthropic still uses ANTHROPIC_API_KEY/x-api-key; there is no Claude credential importer, proxy-only OAuth credential, Bearer subscription profile, or mandatory beta-header handling. No implementation PR was found.

    The remaining blocker is the support contract. Anthropic officially documents Pro/Max login for first-party Claude Code, but the proposed Keychain/file schemas, public client ID, token endpoint, refresh behavior, and private beta header are not documented as a stable third-party integration API. Before implementation, confirm permitted/supported use and define compatibility behavior when Claude Code changes those private details.

    Recommendation

    Route this to a high-priority spike. Validate Anthropic's supported integration contract, token rotation/scopes, and version compatibility; then specify explicit-consent macOS and Linux import adapters. Preserve the security boundary described here: refresh material stays gateway-side, access credentials remain non-injectable, tokens are never logged or displayed, injection is endpoint-scoped, expiry fails closed, and stale-supervisor behavior is tested. Priority is represented by the issue's Priority: High field. Do not apply state:agent-ready; that remains a human decision after the spike.

  7. added
    area:cliCLI-related work
    area:inferenceInference routing and configuration work
    area:gatewayGateway server and control-plane work
    and removed
    state:triage-neededOpened without agent diagnostics and needs triage
    on Jul 11, 2026
  8. TaylorMutch commented on Jul 11, 2026

    @TaylorMutch
    Collaborator

    Thanks for highlighting this issue. Happy to accept a community contribution on this front if this is negatively affecting folks enough.

  9. cjfit commented on Jul 12, 2026

    @cjfit
    Author

    Thanks for highlighting this issue. Happy to accept a community contribution on this front if this is negatively affecting folks enough.

    Awesome @TaylorMutch! I have a fork that implements the strategy proposed in my issue. I'm just in need of a vouch here on my vouch thread so that I can create a PR. Let me know if you're able to do this!

  10. TaylorMutch commented on Jul 13, 2026

    @TaylorMutch
    Collaborator

    @cjfit you're good to go. Look forward to the PR!

  11. github-actions commented on Aug 30, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 7 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  12. johntmyers commented on Sep 14, 2026

    @johntmyers
    Collaborator

    Superseded by #3331, which tracks the unified, workspace-scoped gateway-owned OAuth login framework and the initial Claude Code and Codex provider adapters. The replacement design creates a dedicated OpenShell grant through provider login and does not import or reuse an existing host Claude Code login.

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

Metadata

Metadata

Assignees

Labels

area:cliCLI-related workarea:gatewayGateway server and control-plane workarea:inferenceInference routing and configuration workarea:providersarea:supervisorProxy and routing-path workspikestate:staleInactive item at risk of automatic closure.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions