[BUG] GCP OAuth2 token fetched on every request instead of being cached
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Claude Code version: 2.1.118 (Claude Code)
- Backend: Vertex AI
- Environment variables set:
````
CLAUDE_CODE_USE_VERTEX=1
CLOUD_ML_REGION=global
ANTHROPIC_VERTEX_PROJECT_ID=prj-noncore-dev-totc2
VERTEX_REGION_CLAUDE_3_5_HAIKU=global
Describe the bug
Claude Code appears to call https://oauth2.googleapis.com/token on every outgoing request to Vertex AI, rather than fetching a token once, caching it, and reusing it for up to its 1-hour TTL.
Expected behavior
GCP Bearer tokens are valid for 1 hour. The token should be fetched once per session (or per expiry), cached in memory, and reused for all subsequent Vertex AI requests within that window — consistent with standard GCP client library behavior.
Actual behavior
A call to oauth2.googleapis.com/token is observed before every call to aiplatform.googleapis.com, e.g.:
POST https://oauth2.googleapis.com/token ← repeated every request
POST https://aiplatform.googleapis.com/v1/... ← actual Claude API call
POST https://oauth2.googleapis.com/token ← repeated every request
POST https://aiplatform.googleapis.com/v1/... ← actual Claude API call
...
Impact
- Adds latency to every request (an extra round-trip to Google's auth endpoint)
- Unnecessarily chatty — inflates network traffic and token issuance volume
- May cause rate limiting on
oauth2.googleapis.comin high-usage scenarios
Workaround
None available for CLI users.
What Should Happen?
GCP Bearer tokens are valid for 1 hour. The token should be fetched once per session (or per expiry), cached in memory, and reused for all subsequent Vertex AI requests within that window — consistent with standard GCP client library behavior.
Error Messages/Logs
Steps to Reproduce
Run claude and send hi.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.118 (Claude Code)
Platform
Google Vertex AI
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗