Repository navigation
fix(auth): refresh a short-lived OAuth token once a third of its life has passed, not on every command - #56
Merged
Conversation
… left, not on every command The CLI refreshed a stored OAuth token whenever it had less than 30 minutes left. The API now also issues access tokens that live 15 minutes, which are always inside that window, so every command refreshed before running and a quick run of commands hit the token endpoint's per-address limit (HTTP 429). The window is now 30 minutes or two thirds of the token's lifetime, whichever is shorter: a 15-minute token is refreshed with 10 minutes left, still enough for the default 10-minute wait, and a token that lives 45 minutes or more keeps the 30-minute window. Logins and refreshes record issued_at so the lifetime is known; a profile saved without it keeps the 30-minute window until its next refresh.
The REFRESH_SKEW_MS comment, the OAuth refresh paragraph in docs/usage.md and D-088 still promised every command at least 30 minutes left; for a token that lives less than 45 minutes the window is two thirds of its lifetime instead.
AltaMills
marked this pull request as ready for review
November 18, 2026 06:24
AltaMills
added a commit
that referenced
this pull request
Nov 18, 2026
Version 0.8.7 for the release: a short-lived OAuth token is refreshed once a third of its life has passed instead of before every command (D-095, #56).
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
The CLI refreshed a stored OAuth token whenever it had less than 30 minutes left (D-088). The API now also issues access tokens that live 15 minutes (
expires_in: 900). Such a token is always inside a 30-minute window, so every command refreshed before running, and a quick run of commands (an agent working through a batch) hit the token endpoint's per-address limit with HTTP 429.refreshSkewMs). A 15-minute token is refreshed with 10 minutes left, still enough for the default 10-minutewait. A token that lives 45 minutes or more keeps the 30-minute window, so nothing changes for it.issued_atin the profile, so the lifetime isexpires_at - issued_at. A profile saved by an older CLI has none and keeps the 30-minute window until its next refresh records one.waitlonger than the token's remaining life still ends on its 401, as before; refreshing during a wait is separate work.docs/usage.md(OAuth token refresh) anddocs/decisions.mdD-095.Tests
pnpm build,pnpm typecheck: clean.pnpm test: 717 tests, 716 pass, 1 skipped, 0 fail.tests/refresh-skew.test.ts(the window for 15-, 45- and 60-minute tokens and for a profile withoutissued_at), and threebuildRuntimecases intests/runtime.test.ts(13 minutes left on a 15-minute token: no refresh; 9 minutes left: one refresh that records the 900 s lifetime; noissued_atwith 20 minutes left: refreshed under the 30-minute window).refreshSkewMsto the fixed 30 minutes turns the 15-minute cases red.