fix: require ANTHROPIC_API_KEY for Claude Code / Happy Coder auth #13

Closed
cpfarhood wants to merge 1 commits from fix/claude-code-auth into main
cpfarhood commented 2026-02-20 14:25:14 +00:00 (Migrated from github.com)

Summary

  • Browser-based OAuth login for Claude Code does not work inside the VNC session — the OAuth redirect callback cannot route back into the container
  • When ANTHROPIC_API_KEY is set in the environment, Claude Code skips browser auth and uses the key directly — this is the correct approach for containerized environments
  • The envFrom: secretRef in the Deployment already passes all secret keys as env vars, so users just need to add ANTHROPIC_API_KEY to their existing Kubernetes secret

Changes

  • init-repo.sh: print a clear warning at startup if ANTHROPIC_API_KEY is not set, explaining why Happy Coder won't work
  • chart/values.yaml: document ANTHROPIC_API_KEY in the envSecretName comment so it's visible at deploy time
  • VARIABLES.md: add full ANTHROPIC_API_KEY entry and update the kubectl create secret example to include it

To fix your existing deployment

Add ANTHROPIC_API_KEY to your Kubernetes secret:

kubectl patch secret <your-secret-name> -n <namespace> \
  --type='json' \
  -p='[{"op":"add","path":"/data/ANTHROPIC_API_KEY","value":"'$(echo -n "sk-ant-api03-..." | base64)'"}]'

Or recreate it:

kubectl create secret generic devcontainer-<name>-secrets-env \
  --from-literal=GITHUB_TOKEN='...' \
  --from-literal=VNC_PASSWORD='...' \
  --from-literal=ANTHROPIC_API_KEY='sk-ant-api03-...' \
  --dry-run=client -o yaml | kubeseal --format=yaml | kubectl apply -f -

Then restart the pod to pick up the new env var.

Test plan

  • Add ANTHROPIC_API_KEY to the secret and restart the pod
  • Check logs — warning should NOT appear
  • Open Happy Coder — it should connect without prompting for browser login

🤖 Generated with Claude Code

## Summary - Browser-based OAuth login for Claude Code does not work inside the VNC session — the OAuth redirect callback cannot route back into the container - When `ANTHROPIC_API_KEY` is set in the environment, Claude Code skips browser auth and uses the key directly — this is the correct approach for containerized environments - The `envFrom: secretRef` in the Deployment already passes all secret keys as env vars, so users just need to add `ANTHROPIC_API_KEY` to their existing Kubernetes secret ## Changes - **`init-repo.sh`**: print a clear warning at startup if `ANTHROPIC_API_KEY` is not set, explaining why Happy Coder won't work - **`chart/values.yaml`**: document `ANTHROPIC_API_KEY` in the `envSecretName` comment so it's visible at deploy time - **`VARIABLES.md`**: add full `ANTHROPIC_API_KEY` entry and update the `kubectl create secret` example to include it ## To fix your existing deployment Add `ANTHROPIC_API_KEY` to your Kubernetes secret: ```bash kubectl patch secret <your-secret-name> -n <namespace> \ --type='json' \ -p='[{"op":"add","path":"/data/ANTHROPIC_API_KEY","value":"'$(echo -n "sk-ant-api03-..." | base64)'"}]' ``` Or recreate it: ```bash kubectl create secret generic devcontainer-<name>-secrets-env \ --from-literal=GITHUB_TOKEN='...' \ --from-literal=VNC_PASSWORD='...' \ --from-literal=ANTHROPIC_API_KEY='sk-ant-api03-...' \ --dry-run=client -o yaml | kubeseal --format=yaml | kubectl apply -f - ``` Then restart the pod to pick up the new env var. ## Test plan - [ ] Add `ANTHROPIC_API_KEY` to the secret and restart the pod - [ ] Check logs — warning should NOT appear - [ ] Open Happy Coder — it should connect without prompting for browser login 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.