feat(claude-code): add manual auth flow for remote environments #10549
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.
Summary
This PR attempts to address Issue #10531 where Claude Code sign-in is broken in remote environments (like GitHub Codespaces) due to hardcoded localhost redirectUri.
Changes
Based on the feedback from @soundyogi, this implements a manual authorization code entry flow similar to how Claude Code itself handles this scenario:
Backend Changes (
src/integrations/claude-code/oauth.ts)oobRedirectUriconstant for OOB (out-of-band) OAuth flowbuildManualAuthorizationUrl()function using OOB redirectexchangeManualCodeForTokens()function for manual code exchangestartManualAuthorizationFlow()method toClaudeCodeOAuthManagerexchangeManualCode()method to exchange manually-entered codeshasPendingManualAuth()helper methodFrontend Changes (
webview-ui/src/components/settings/providers/ClaudeCode.tsx)Message Handler Updates (
src/core/webview/webviewMessageHandler.ts)claudeCodeStartManualAuthcase to start manual auth flowclaudeCodeSubmitManualCodecase to exchange manually-entered codesType Definitions
claudeCodeStartManualAuthandclaudeCodeSubmitManualCodetoWebviewMessage.tsclaudeCodeManualAuthStartedtoExtensionMessage.tsHow It Works
Testing
src/andwebview-ui/Note
The OOB redirect URI (
urn:ietf:wg:oauth:2.0:oob) is a standard OAuth pattern. However, whether Anthropic's OAuth endpoint supports this redirect URI needs to be verified. If they use a different approach (like a custom callback page), the implementation may need adjustment.Feedback and guidance are welcome!
Important
Add manual OAuth flow for remote environments in Claude Code, including backend, frontend, and message handler updates.
oauth.ts):oobRedirectUrifor OOB OAuth flow.buildManualAuthorizationUrl()andexchangeManualCodeForTokens()for manual code handling.startManualAuthorizationFlow()andexchangeManualCode()toClaudeCodeOAuthManager.ClaudeCode.tsx):webviewMessageHandler.ts):claudeCodeStartManualAuthandclaudeCodeSubmitManualCodecases for manual auth flow.claudeCodeStartManualAuthandclaudeCodeSubmitManualCodetoWebviewMessage.ts.claudeCodeManualAuthStartedtoExtensionMessage.ts.This description was created by
for 63afd92. You can customize this summary. It will automatically update as commits are pushed.