Skip to content

fix: respect CLAUDE_CODE_OAUTH_TOKEN env authentication check in standalone mode#774

Open
iamriajul wants to merge 3 commits intocoder:mainfrom
iamriajul:patch-2
Open

fix: respect CLAUDE_CODE_OAUTH_TOKEN env authentication check in standalone mode#774
iamriajul wants to merge 3 commits intocoder:mainfrom
iamriajul:patch-2

Conversation

@iamriajul
Copy link
Contributor

Description

Update the authentication guard to support multiple authentication paths.
Previously, authentication setup was skipped unless CLAUDE_API_KEY was present. This change allows the setup to proceed when either CLAUDE_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or ARG_ENABLE_AIBRIDGE=true is provided.

This ensures OAuth-based flows and AIBridge-enabled environments work correctly without requiring an API key.


Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Testing & Validation

  • Tests pass (bun test) (not applicable — shell logic change)
  • Code formatted (bun fmt) (not applicable)
  • Changes tested locally

Tested scenarios:

  • ✅ API key present → auth setup runs
  • ✅ OAuth token present → auth setup runs
  • ✅ AIBridge enabled without keys → auth setup runs
  • ✅ No auth inputs → setup correctly skipped

Related Issues

None

…andalone mode

Update guard condition to skip authentication only when:
- CLAUDE_API_KEY is unset
- CLAUDE_CODE_OAUTH_TOKEN is unset
- ARG_ENABLE_AIBRIDGE is false

This enables authentication flow for OAuth-based usage and AIBridge scenarios.
@iamriajul iamriajul marked this pull request as ready for review March 1, 2026 06:02
@matifali matifali requested a review from 35C4n0r March 2, 2026 05:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Claude Code module’s standalone-mode install script so authentication setup runs for OAuth-token and AI Bridge flows (not only API-key flows), aligning behavior with the module’s supported authentication options.

Changes:

  • Expand the standalone-mode authentication guard to proceed when CLAUDE_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or enable_aibridge is set.
  • Update README examples to reference module version 4.7.6.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
registry/coder/modules/claude-code/scripts/install.sh Adjusts standalone-mode auth gating to include OAuth token and AI Bridge paths.
registry/coder/modules/claude-code/README.md Bumps example module version strings to 4.7.6.

Comment on lines +182 to +185
if [ -z "${CLAUDE_API_KEY:-}" ] \
&& [ -z "${CLAUDE_CODE_OAUTH_TOKEN:-}" ] \
&& [ "${ARG_ENABLE_AIBRIDGE:-false}" = "false" ]; then
echo "Note: No CLAUDE_API_KEY, no CLAUDE_CODE_OAUTH_TOKEN, and AIBridge disabled — skipping authentication setup"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard now allows standalone configuration to run when only CLAUDE_CODE_OAUTH_TOKEN is set, but the code below still unconditionally writes .primaryApiKey to ${CLAUDE_API_KEY:-}. In an OAuth-only flow this will set primaryApiKey to an empty string and can clobber an existing API key in ~/.claude.json. Consider only updating/setting primaryApiKey when CLAUDE_API_KEY is non-empty (otherwise preserve the existing value or omit the field).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants