Skip to content

X01 - Model credential via the proxy

Purpose: The result of the spike for I60I60 (closed): X01-model-credential: API key mode via the proxySplit from #15 (X01-model-credential) during triage on 2026-10-04., the part of I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? that doesn’t need a browser login, and for the browser login in I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? (“Browser login (I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?)”). Does Claude Code work with a placeholder credential while a host-side proxy injects the real one, and which hosts does it contact, for the model API profile of S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host.?

Requirements: SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter., FR01-drop-inFR01-drop-in: Drop-in for claudewb is the single entry point for everything, structured as wb [wb flags] <command> [command args]., FR13-claude-stateFR13-claude-state: Claude Code state per projectClaude Code's conversation history, and the state it keeps only in the guest, persist per project, so --resume/--continue work within a project.

Brief: B60-model-credentialB60-model-credential: Can Claude Code in the guest hold only a placeholder while the proxy adds the real subscription token?Yes, for a long-lived token from claude setup-token., and B15-browser-loginB15-browser-login: Can Claude Code in the guest run on a browser login while the host keeps the real tokens?Yes, with conditions. for I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?

The long-lived token (I60, decided 2026-10-12)

Section titled “The long-lived token (I60, decided 2026-10-12)”

From X00-indexX00-index: SpikesThe open questions that must be answered by a throwaway prototype before work builds on them, in the order they are taken up.: does Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? I60I60 (closed): X01-model-credential: API key mode via the proxySplit from #15 (X01-model-credential) during triage on 2026-10-04. asks it for the modes that don’t need a browser: an API key, and, since the maintainer signs in through enterprise SSO and has no API key, a long-lived token from claude setup-token.

Mode Answer Evidence
Long-lived subscription token (claude setup-token, CLAUDE_CODE_OAUTH_TOKEN) yes measured, below
API key (ANTHROPIC_API_KEY) open not run: no API key. Moved to I253I253 (open): X01-model-credential: API key mode end to end via the proxyDoes Claude Code work end to end in API key mode with a placeholder API key while wb-proxyd injects the real key in x-api-key?. OpenShell’s Claude Code provider shows an API key works this way (X00-indexX00-index: SpikesThe open questions that must be answered by a throwaway prototype before work builds on them, in the order they are taken up., S09-05-credentialsS09-05-credentials: CredentialsHow credentials are stored and bound to requests, and how the model credential reaches the model API without entering the guest., “Model credential”)
Browser login (/login, SSO) and its token refresh yes, with conditions measured 2026-10-15, “Browser login (I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?)”

Yes for the long-lived token. Claude Code 2.1.289 sends the placeholder as Authorization: Bearer <placeholder>, only to api.anthropic.com, with anthropic-beta: oauth-2025-04-20. The proxy replaced the placeholder on all 36 requests that held it, and every model call returned 200.

Step Result
claude -p pong, is_error: false, 1.8 s
claude -p --resume <session> I replied with "pong"., same session
claude, interactive no key prompt. One question asked, and answered
claude --resume <session>, interactive opened the session full screen. The maintainer left without a question, so no second answer was seen

The run was on 2026-10-12, on the host as the test user wbtest (I188I188 (closed): X01-model-credential: set up the test account and Keychain item for API key mode1., I214I214 (closed): X01-model-credential: run the API key spike as wbtestThe spike code is ready on spike/x01-model-credential (eed5dd0): a TLS-inspecting proxy that reads the key from wraithbox-secret and swaps it in for a placeholder, and run.sh, which runs -p, -p --resume, an…), with no VM. Claude Code 2.1.289 had HTTPS_PROXY pointed at a throwaway Go proxy on 127.0.0.1 and NODE_EXTRA_CA_CERTS naming the proxy’s CA, which only that process trusted. The proxy read the token from the Keychain item wraithbox-secret in wbtest’s login Keychain. The token and the placeholder are both 108 characters. The proxy logged method, host, path, header names and its verdict per request, never a value.

The proxy was set to inject the token on api.anthropic.com, console.anthropic.com, platform.claude.com and claude.ai, to learn which hosts take it. Only api.anthropic.com received it.

claude setup-token --help, run by the builder on the host as its own user with the same Claude Code 2.1.289, prints “Set up a long-lived authentication token (requires Claude subscription)”. It doesn’t give a lifetime.

70 TLS connections, 72 requests. The proxy inspected the connections to all five hosts. Counts are requests.

Host Path Requests Token sent Answer What it is
api.anthropic.com /v1/messages 5 yes 200 the model. Inferred from timing and anthropic-beta: 3 main-loop calls, one per answered prompt, and 2 side calls
/api/event_logging/v2/batch 10 yes 200 Anthropic’s own telemetry
/api/eval/sdk-zAZezfDKGoZuXXKe 4 yes 200 feature flag evaluation (inferred from the path)
/api/claude_code/policy_limits 5 yes 200, 304 the organization’s limits
/api/claude_code/settings 5 yes 404 remote managed settings. None are set for this account
/api/claude_cli/bootstrap 7 yes 403 refused every time. Claude Code carried on
/mcp-registry/v0/servers 16 no 200 the public MCP server registry
/api/hello 1 no 200 a reachability check, interactive start
platform.claude.com /v1/oauth/hello 1 no 200 a reachability check of the login host, interactive start. No token was refreshed
downloads.claude.ai /claude-code-releases/latest, then 2.1.296/manifest.json, manifest.zst.json, manifest.json.raw-sig.json, darwin-arm64/claude.zst 10 no 200 the auto-updater. It fetched the 2.1.296 build once in each interactive session
/claude-code-releases/plugins/claude-plugins-official/latest, then one .zip 2 no 200 the official plugin marketplace
http-intake.logs.us5.datadoghq.com /api/v2/logs 5 no 202 Datadog log intake, with Claude Code’s built-in DD-API-KEY (X22-no-guest-credentialsX22-no-guest-credentials: Clients without guest credentialsWhich common clients (Homebrew against ghcr.io, git, gh, npm, pip, uv, SwiftPM, Go, cargo, Claude Code) break when wb-proxyd removes every guest-supplied Authorization header and cookie on inspected hosts?). The fifth was cut off when the run ended
raw.githubusercontent.com /anthropics/claude-code/refs/heads/main/CHANGELOG.md 1 no 200 the changelog, shown at interactive start

-p alone reached api.anthropic.com and Datadog. The updater, the plugin marketplace, the changelog, and the two reachability checks came only with an interactive session. The proxy didn’t see a cookie in any request. It didn’t see the placeholder in the Authorization or x-api-key header of a request to a host other than api.anthropic.com. It didn’t look anywhere else in a request (“Limits”).

  • Keychain: no item with claude or anthropic in its service or account name. With the token in the environment, Claude Code didn’t make a credential item.
  • Files: ~/.claude.json (51.4 KiB) and, under ~/.claude/, settings.json, history.jsonl, policy-limits.json, an empty remote-settings.json, and the projects, sessions, plugins, backups and cache directories. No .credentials.json.
  • The real token on disk: a fixed-string search of wbtest’s home, skipping ~/Library/Keychains, didn’t find a file holding it.

Neither search can be told apart from a failed one in this run. The token went to grep -f through a pipe from security -w, and if that had failed, grep would have had no pattern and wouldn’t have matched anything. The Keychain listing hid the errors of security dump-keychain. The proxy read the same item at start, which makes a failed read unlikely, but the run didn’t check it. run.sh now fails in both cases (commits 2a83a3a and 2801f5f).

An earlier run in API key mode found a bug in the spike proxy, not in Claude Code. The proxy wrote HTTP/2 status lines to its HTTP/1.1 client, and Claude Code failed with Malformed_HTTP_Response. It did show that Claude Code sends a placeholder ANTHROPIC_API_KEY as x-api-key to api.anthropic.com, and the proxy replaced it there. The item didn’t hold an API key, so /v1/messages answered 401.

The pull request with this result didn’t change them. The maintainer decided the open points on I60I60 (closed): X01-model-credential: API key mode via the proxySplit from #15 (X01-model-credential) during triage on 2026-10-04. on 2026-10-12, and I215I215 (closed): Model API profile and token binding from X01-model-credentialThe X01-model-credential result for a long-lived subscription token (#60, docs/spikes/X01-model-credential.md) changes the specs below. made these changes:

The run on 2026-10-15, with the maintainer, answers the rest of I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? except API key mode, which moved to I253I253 (open): X01-model-credential: API key mode end to end via the proxyDoes Claude Code work end to end in API key mode with a placeholder API key while wb-proxyd injects the real key in x-api-key? because there is no key to run it with.

Yes, with conditions. Claude Code 2.1.296 works on a browser login when its store holds placeholder access and refresh tokens and a host-side proxy holds the real pair. The proxy put the real access token into Authorization: Bearer, and answered Claude Code’s refresh itself, so the real refresh token never reached Claude Code.

Step Result
claude -p, store expired refreshed first, then pong, is_error: false
claude -p --resume <session>, store expired again refreshed with the refresh token the proxy got back, then I replied with "pong".
claude, interactive one question asked, and answered

The conditions:

  • Only the host refreshes. Every refresh returned a new refresh token. With a second holder of the same login, each would have to learn the other’s new token.
  • The login comes from outside the guest. In the run it came from a real /login on the host’s test user, moved out of Claude Code’s store by the spike’s swap.
  • A login lasts about 30 days. A refresh doesn’t move the refresh token’s deadline. The user signs in again when it passes.

For the question from S14-claude-in-guestS14-claude-in-guest: Claude Code in the GuestHow Claude Code gets into the guest image, which of the user's Claude Code configuration goes with it, how it starts, and the agent interface that keeps Claude Code's specifics in one place (V1-02-claude-only).: no, refusing /v1/oauth/hello doesn’t stop the login prompt. Claude Code builds the authorize URL, with its PKCE challenge, without a request.

On the host as wbtest, in a su - wbtest terminal, with Claude Code 2.1.296 and the spike proxy set up as on 2026-10-12. login.sh ran five steps: deny, observe, placeholder, restore and nokeychain, then a /logout through the proxy. The maintainer signed in with the enterprise SSO account that made the long-lived token of 2026-10-12.

The proxy logged hosts and paths. On a path holding oauth or token it logged the body’s field names, with values only for fields that aren’t secret (grant_type, client_id, scope, expires_in and the like), and string lengths for the rest. It scanned every header, the query and the body of every request for the two placeholders.

The first deny and observe runs are void. login.sh set its EXIT trap inside a function, and zsh runs such a trap when the function returns, so the proxy stopped before Claude Code started. Claude Code met a closed port, and the login failed. Commit 7f2d9a1 fixed it, and both steps ran again.

What Measured
Authorize https://claude.com/cai/oauth/authorize, with code=true, response_type=code, redirect_uri=https://platform.claude.com/oauth/code/callback, an S256 PKCE challenge, state, and the public client ID 9d1c250a-e61b-44d9-88ed-5944d1962f5e. The browser shows a code, which the user pastes into Claude Code
Scopes asked: org:create_api_key, user:profile, user:inference, user:sessions:claude_code, user:mcp_servers, user:file_upload, user:plugins. Granted: all but org:create_api_key
Reachability check GET platform.claude.com/v1/oauth/hello, 200, after the code was pasted and before the exchange. Seen in one of the two logins (nokeychain)
Exchange POST platform.claude.com/v1/oauth/token, a JSON body: grant_type=authorization_code, code (48 characters), code_verifier (43), state (43), client_id and redirect_uri. No client secret
Tokens 200: access_token (108 characters), expires_in=28800 (8 hours), refresh_token (108), refresh_token_expires_in (below), scope, token_type=Bearer, token_uuid, and account and organization objects
After the login GET on api.anthropic.com, with the token: /api/oauth/profile, /api/oauth/claude_cli/roles and /api/organization/claude_code_first_token_date
Stored in the login Keychain, item Claude Code-credentials: one JSON value whose field claudeAiOauth holds accessToken, refreshToken, expiresAt (milliseconds), scopes, subscriptionType (enterprise), rateLimitTier and an empty refreshTokenExpiresAt. No .credentials.json

x01-proxy swap moved the real pair into the Keychain item wraithbox-oauth, and wrote placeholders of the same length into Claude Code’s item, with expiresAt an hour in the past.

  • Request. Claude Code refreshed before its first model call: POST platform.claude.com/v1/oauth/token, a JSON body with grant_type=refresh_token, refresh_token, client_id, and scope set to the granted list. No client secret.
  • Swap. The proxy put the real refresh token into the body, and the placeholders into the answer in place of the new real tokens. Claude Code then stored the placeholders with expiresAt 8 hours ahead.
  • Rotation. Both refreshes answered 200, with a new access token and a new refresh token each time, and expires_in=28800.
  • Fixed deadline. refresh_token_expires_in fell with the clock across both refreshes and the restore: 2,472,894 s at 19:42, 2,472,627 at 19:47 and 2,472,374 at 19:51. The deadline is set at login. A new login at 19:54 got 2,579,568 s, about 29.9 days.
  • Old refresh tokens still work. The proxy failed to save the rotated pairs (security add-generic-password -U exited 45, a spike bug fixed in 5dabd68), so its item kept the first pair. The restore step put that pair back, and Claude Code refreshed with the first refresh token at 19:51, about five minutes after it had been rotated twice: 200. Rotation doesn’t revoke the old refresh token, at least not within five minutes.
  • The scan found a placeholder in one place only: the body of the refresh request to platform.claude.com, where the proxy swaps it. No other header, query string, or body had one.
  • The proxy checks each token answer for a real token it holds before the answer goes to Claude Code, and found none.
  • A fixed-string search of wbtest’s home for the first real pair, outside ~/Library/Keychains, didn’t find a file. The pairs from the two refreshes were in the proxy’s memory only and weren’t searched for.

With the browser login, Claude Code also reached these paths on api.anthropic.com, with the token: /api/oauth/organizations/<org>/marketplaces, plugins/list-plugins, plugins/<id>/download, skills/list-skills and skills/<name>/download. It downloaded nine skills and one plugin of the maintainer’s organization, as zip files of 5 to 173 KB, into ~/.claude/skills and ~/.claude/plugins. The long-lived token of 2026-10-12 reached none of these paths.

In the su terminal with the login Keychain locked, /login worked, and Claude Code wrote the login in plaintext to ~/.claude/.credentials.json (mode 0600, 528 bytes), without a message. With the Keychain unlocked again, Claude Code still read the file, and /logout deleted it.

Logged out, with the proxy refusing all of platform.claude.com, claude.ai and console.anthropic.com, /login printed the authorize URL. The proxy saw 23 connections in that session, to api.anthropic.com, downloads.claude.ai and Datadog, and none to a refused host, so it refused no request.

/logout sent POST platform.claude.com/v1/oauth/token/revoke, a JSON body with token (108 characters), token_type_hint (13, the length of refresh_token) and client_id. It answered 200 with an empty body. Claude Code then deleted its store and exited. Whether revoking the newest refresh token also revokes the older ones of the same login wasn’t tested.

With the restored login, and with the login read from .credentials.json, the banner said “API Usage Billing” where it otherwise said “Claude Enterprise”. The model answered either way. Why wasn’t checked.

  • One enterprise SSO account, one Mac, one run, Claude Code 2.1.296. A Pro or Max login may differ in scopes, lifetimes, and paths.
  • On the host, not in a guest.
  • One check of an old refresh token, five minutes after the rotation.
  • Claude Code refreshed when expiresAt had passed. Whether it also refreshes on a 401, or never does when expiresAt lies far ahead, wasn’t tested.
  • /v1/oauth/hello showed in one login of two.
  • The tokens from the two refreshes stayed in the proxy’s memory, weren’t searched for on disk and weren’t revoked by name.

The pull request with this result doesn’t change them. The maintainer decided on I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh? on 2026-10-15: the browser login isn’t in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. (I257I257 (open): Host-side browser login for the model credential (after V1)A host-side browser login for the model credential, deferred past V1 by the B15-browser-login decision on #15 (2026-10-15, option B not chosen for V1). keeps the design), and the authorize URL gets no filter. I256I256 (closed): S14-claude-in-guest, S09-policy-credentials-audit: browser login decisions from B15-browser-loginSpec changes from the B15-browser-login decisions on #15 (2026-10-15). makes these changes:

Branch spike/x01-model-credential, commit 2801f5f: the proxy, its tests, and run.sh. The run on 2026-10-12 used run.sh as of 768cc28, before the search checks. The logs stay on the maintainer’s Mac. They don’t hold a credential.

For I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?, commit 5dabd68: login.sh, and the proxy’s deny rules, field logging, full-request scan, OAuth store and swap. The runs on 2026-10-15 used the proxy as of e499d3b and login.sh as of 7f2d9a1, and the restore step as of 5dabd68. Their logs stay on the maintainer’s Mac and don’t hold a token.

Status: Answered 2026-10-12: yes for a long-lived token. Decided 2026-10-12 (I60I60 (closed): X01-model-credential: API key mode via the proxySplit from #15 (X01-model-credential) during triage on 2026-10-04.): A2, the model only with the event log denied by the host, and the long-lived token as a supported mode for V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. Answered 2026-10-15 (I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?): yes, with conditions, for the browser login. Decided 2026-10-15 (I15I15 (closed): X01-model-credential: Model credential via the proxyDoes Claude Code work with a placeholder credential while wb-proxyd injects the real one, for each supported authentication mode, including token refresh?): not in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there., and no filter for the authorize URL