Skip to content

HUD usage shows [API err] when multiple Keychain entries exist for Claude Code-credentialsΒ #1682

@sunwoongc

Description

@sunwoongc

Summary

The HUD usage-api.ts reads OAuth credentials from macOS Keychain using find-generic-password -s "Claude Code-credentials" without specifying an account (-a). When multiple entries exist under the same service name (e.g., after a re-login where Claude Code creates a new entry with a different account name), macOS returns the oldest entry β€” which may have expired tokens β€” causing [API err] in the HUD.

Root Cause

Claude Code previously stored Keychain credentials with account "Claude Code", but newer versions use the user's system username (e.g., "sunwoong"). After claude logout && claude login, a new entry is created alongside the stale one. find-generic-password -s without -a returns the first match (the old expired entry), so the HUD never sees the fresh tokens.

Suggested Fix

Enumerate all genp entries matching the service name and pick the one with the latest expiresAt (freshest token). This avoids depending on a specific account name and is forward-compatible with future Claude Code credential storage changes.

Environment

  • macOS (Keychain-based credential storage)
  • OMC v4.8.2
  • Claude Code CLI (post-credential format change)

Workaround

Delete the stale Keychain entry manually:

security delete-generic-password -s "Claude Code-credentials" -a "Claude Code"

πŸ€– Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsRelated to agent definitionsquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions