Skip to content

feat: add non-interactive auth via CLAUDE_CODE_OAUTH_TOKEN#32

Merged
akshithg merged 3 commits intomainfrom
feat/noninteractive-auth
Mar 12, 2026
Merged

feat: add non-interactive auth via CLAUDE_CODE_OAUTH_TOKEN#32
akshithg merged 3 commits intomainfrom
feat/noninteractive-auth

Conversation

@akshithg
Copy link
Copy Markdown
Member

Summary

  • Forward CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_API_KEY from host into container via containerEnv
  • Add setup_onboarding_bypass() to post_install.py: runs claude -p to populate auth state, then sets hasCompletedOnboarding: true so the TUI skips the login wizard
  • Document token-based auth in README

Workaround for anthropics/claude-code#8938.

Test plan

  • Token flow: set CLAUDE_CODE_OAUTH_TOKEN, build fresh container — ~/.claude.json has hasCompletedOnboarding: true
  • Rebuild persistence: devcontainer up --remove-existing-containerpostCreateCommand re-runs, auth state recreated
  • No token: without the env var, setup_onboarding_bypass() is a no-op (no regression)

🤖 Generated with Claude Code

Bypass the interactive onboarding wizard when CLAUDE_CODE_OAUTH_TOKEN is
set. On container create, post_install.py runs `claude -p` to populate
auth state and sets hasCompletedOnboarding so the TUI starts without the
login wizard.

Workaround for anthropics/claude-code#8938.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
akshithg and others added 2 commits March 11, 2026 19:49
containerEnv bakes values into the image as ENV instructions, visible
in docker inspect/history. remoteEnv is set at runtime only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Handle timeout as expected (claude -p writes config before API call)
- Catch FileNotFoundError/OSError if claude is not installed
- Check returncode explicitly instead of dead CalledProcessError catch
- Guard on ~/.claude.json existence before writing onboarding flag
- Replace contextlib.suppress with explicit try/except that logs
- Update module docstring and README wording

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@akshithg akshithg merged commit 5a2b92a into main Mar 12, 2026
3 checks passed
@akshithg akshithg deleted the feat/noninteractive-auth branch March 12, 2026 13:36
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