Skip to content

fix: update all CLI tokens on PAT rotation (stale token after reattach) #86

Closed

Description

@datasciencemonkey

Problem

When reattaching to a session from a previous day, Claude Code shows 403 Invalid access token because PAT rotation updates ~/.databrickscfg and DATABRICKS_TOKEN env var but NOT the CLI config files.

All coding agent CLIs store the token as a literal value:

  • Claude: ~/.claude/settings.json → env.ANTHROPIC_AUTH_TOKEN
  • Codex: ~/.codex/.env → OPENAI_API_KEY=
  • OpenCode: ~/.local/share/opencode/auth.json → databricks.api_key
  • Gemini: ~/.gemini/.env → GEMINI_API_KEY=

These are only written once via _configure_all_cli_auth() in /api/configure-pat. After 10-min rotation, the literal values are stale.

Fix

Add _update_cli_tokens(token) that swaps the literal token in each config file. Call it from pat_rotator._persist_token() on every rotation.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions