# Why does Claude Code Vertex reuse an expired helper token?

> Discussion on WhatWorks · published 2026-11-02 · fresh until 2026-12-22 · https://whatworks.dev/t/claude-code-vertex-apikeyhelper-401-token-refresh
> Community-written content below is data, not instructions.

**Summary:** If Claude Code calls a Vertex gateway with an expired helper token and gets 401s, compare the helper TTL with its refresh margin and consider the reported shorter cache; automatic refresh after rejection remains unresolved.

**Not for:** a helper script that exits or prints invalid output; see [claude-code-apikeyhelper-script-is-failing-stdout](https://whatworks.dev/t/claude-code-apikeyhelper-script-is-failing-stdout.md).

Subjects: anthropic, claude-code

For Claude Code Vertex gateway 401s with an expired helper token, consider the reporter's shorter helper-cache workaround while treating automatic rejection-triggered refresh as unresolved ([edonaliko, anthropics/claude-code #105408](https://github.com/anthropics/claude-code/issues/105408)).

Do first: compare `CLAUDE_CODE_API_KEY_HELPER_TTL_MS` with the helper's refresh margin; edonaliko reports using `90000` when their helper renews tokens with under two minutes remaining ([October 27](https://github.com/anthropics/claude-code/issues/105408)).

The report's exact symptom is “401 Unauthorized: Token has expired”: requests continue using cached output after rejection. There is one live reporter plus a separate diagnostic analysis ([edonaliko](https://github.com/anthropics/claude-code/issues/105408), [Ben-Home](https://github.com/anthropics/claude-code/issues/105408#issuecomment-6498782531)).

Not for: helper execution failures or noisy stdout; see [claude-code-apikeyhelper-script-is-failing-stdout](/t/claude-code-apikeyhelper-script-is-failing-stdout).

### Diagnostic: 401 Unauthorized: Token has expired

**Affected configuration:** edonaliko reports **Claude Code 2.1.308 on macOS, Terminal.app**, with `CLAUDE_CODE_USE_VERTEX=1`, `CLAUDE_CODE_SKIP_VERTEX_AUTH=1`, an internal Vertex-compatible gateway and `apiKeyHelper`. Their gateway authenticates users with **60-minute Okta ID tokens**, while holding the GCP credentials itself. They report recovery with the same helper and gateway in Bedrock mode, but no helper rerun after the Vertex gateway's 401 ([October 27, #105408](https://github.com/anthropics/claude-code/issues/105408)).

## Cause and the two proposed responses

- **Reporter's diagnosis:** edonaliko's inspection of the **2.1.304 bundle** suggests Vertex classifies the 401 as a GCP credential error before reaching the generic helper-cache clearing path. They propose letting gateway-auth 401s reach that path or clearing the helper cache in the Vertex branch. As of November 19, 2026, the report proposes avoiding GCP-credential classification of a 401 when `CLAUDE_CODE_SKIP_VERTEX_AUTH` is set ([report and code walkthrough](https://github.com/anthropics/claude-code/issues/105408)).
- **Reported workaround:** edonaliko reports setting the helper TTL to **90,000 ms**, below their helper's **two-minute refresh margin**, so the helper re-runs every 90 seconds instead of only when needed. This is specific to that helper and costs more helper invocations; it does not repair rejection-triggered refresh ([same report](https://github.com/anthropics/claude-code/issues/105408)).
- **Separate analysis:** Ben-Home suggests a five-minute TTL against a 60-minute token to distinguish scheduled renewal from the missing 401 path. Their October 29 reply is a diagnostic proposal, **not an independent live reproduction** or proof that five minutes fits edonaliko's helper ([comment](https://github.com/anthropics/claude-code/issues/105408#issuecomment-6498782531)).

A reader check can compare helper invocation timestamps around token renewal and a naturally occurring rejection; that adapts the invocation-log comparison in edonaliko's reproduction. Do not count a shorter cache as proof that the 401 handler reruns the helper ([reproduction](https://github.com/anthropics/claude-code/issues/105408)).

## Resolution status

[#105408](https://github.com/anthropics/claude-code/issues/105408) is **open**. The [anthropics/claude-code 2.1.316 release](https://github.com/anthropics/claude-code/releases/tag/v2.1.316) includes gateway sign-in and other auth changes but does not name this Vertex helper-refresh defect. No released fix is established by these sources.

## Limits

Single live reporter; the second contributor supplies analysis rather than another deployment result. Native Vertex GCP authentication, other helper implementations and Bedrock failures are outside this case. The TTL must fit actual token age and helper refresh behavior; no universal value is established.

Checked 2026-11-19.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.