fix: OAuth credential proxy — auto-refresh tokens + beta header#1076
Closed
glifocat wants to merge 1 commit into
Closed
fix: OAuth credential proxy — auto-refresh tokens + beta header#1076glifocat wants to merge 1 commit into
glifocat wants to merge 1 commit into
Conversation
OAuth users hitting 401 "OAuth authentication is currently not supported" because the proxy was missing the required `anthropic-beta: oauth-2025-04-20` header. Additionally, tokens in .env expire after ~4 hours with no refresh. Changes: - Add src/oauth-token.ts: reads ~/.claude/.credentials.json, caches tokens in memory, auto-refreshes via platform.claude.com when expired, serializes concurrent refreshes through a promise chain, writes back atomically - Rewrite credential proxy: async handler, unconditional credential injection (no exchange-based flow), beta header for OAuth, req.pipe() streaming, /health endpoint, JSON error responses, 10-min timeout - Update tests for new behavior (mock getFreshOAuthToken, process.env for upstream URL, unconditional OAuth injection assertions) Based on work by @calebfaruki (nanocoai#871) and @kianwoon (nanocoai#930/nanocoai#969). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4ff6391 to
eb22f58
Compare
pillaiinfotechbot
pushed a commit
to pillaiinfotechbot/nanoclaw-updated
that referenced
this pull request
Apr 2, 2026
Adds /Users/mac/Development as /workspace/extra/Development in every agent container, same pattern as the sysbridge mount. Resolves tasks nanocoai#855, nanocoai#1070, nanocoai#1071, nanocoai#1073, nanocoai#1075, nanocoai#1076, nanocoai#1077 — agents can now access project repos from within their Docker containers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
thats2easyyy
added a commit
to thats2easyyy/nanoclaw
that referenced
this pull request
Apr 8, 2026
…conditionally Without this, OAuth tokens hit 401 "OAuth authentication is currently not supported" because api.anthropic.com requires the oauth-2025-04-20 beta feature flag for Bearer-auth requests. The previous code only injected on requests where the container already sent an Authorization header, which never happens on the non-exchange SDK path. Also resolves a merge conflict from the native-credential-proxy skill: HEAD retained a stray ONECLI_URL export in src/config.ts that conflicted with the skill's CREDENTIAL_PROXY_PORT addition. Took the skill's side. Matches the approach in upstream PR nanocoai#1076 (still open at time of commit). Relevant issue: nanocoai#730 (OAuth tokens expire overnight). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
.claude/skills/Description
OAuth users are hitting 401 "OAuth authentication is currently not supported" because the credential proxy doesn't send the required
anthropic-beta: oauth-2025-04-20header. Additionally, OAuth tokens stored in.envexpire after ~4 hours with no automatic refresh, causing silent auth failures.This PR fixes both issues:
1. Beta header injection (
credential-proxy.ts):anthropic-beta: oauth-2025-04-20on all OAuth-proxied requestsreq.pipe()streaming for large request bodies (base64 images)/healthendpoint, JSON error responses (502/503), 10-min timeout2. Token auto-refresh (new
oauth-token.ts):~/.claude/.credentials.json(same file theclaudeCLI maintains)platform.claude.com/v1/oauth/token.envtoken if credentials file is unavailableBased on work by @calebfaruki (#871) and @kianwoon (#930, #969). Supersedes both PRs with a combined, tested implementation.
Related issues: #730 (OAuth tokens expire)