Repository navigation
fix(quota): never refresh or rewrite Claude Code's credentials - #306
Merged
Merged
Conversation
The quota service read ~/.claude/.credentials.json and, when the access token was within five minutes of expiry, posted Claude Code's refresh token to the OAuth token endpoint and wrote the new tokens back into Claude Code's credentials file. It did this on by default, with no coordination with Claude Code's own refresh and no backoff: one install's logs showed 855 rejected refresh attempts, up to about 270 in a day. Tether now only reads the access token: - An expired token makes no request. The footer keeps the last observation and reports quota as paused until Claude Code refreshes its sign-in. - A 401/403 on a non-expired token backs off per token (5 to 60 minutes). A successful response or a new token in the file resets it. - The refresh request, the client id, the token endpoint and every write to the credentials path are removed. The refresh token is no longer read into memory. Docs describe how Claude quota is obtained and that the usage endpoint is not a documented API. Tests: expired token makes no request and retains the last reading; a valid token makes exactly one usage request; no case refreshes or writes; rejection backoff and reset on token change. Co-Authored-By: OpenAI Codex <noreply@openai.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Review section 2 (
docs/REVIEW_2026-11-09.md).The quota service refreshed Claude Code's OAuth token itself and wrote the result back into
~/.claude/.credentials.json. It was on by default, undocumented, uncoordinated with Claude Code's own refresh, and retried a rejected refresh every five minutes with no backoff.usage-quota.mdandsettings.mdnow say how Claude quota is obtained and that the endpoint is not a documented API.Codex quota, the polling interval and the public service API are unchanged.
Test plan
npx tsc --noEmitnpx eslint src/main/quotanpx vitest run src/main/quota— 12 passed~/.claude/.credentials.jsonmodification time does not change while only Tether is runningOut of scope
🤖 Generated with Claude Code