Skip to content

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

@datasciencemonkey

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.jsonenv.ANTHROPIC_AUTH_TOKEN
  • Codex: ~/.codex/.envOPENAI_API_KEY=
  • OpenCode: ~/.local/share/opencode/auth.jsondatabricks.api_key
  • Gemini: ~/.gemini/.envGEMINI_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

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions