fix: preserve refresh token when token endpoint omits it (→ 0.6.1) - #16
Merged
Conversation
Per RFC 6749 §6, a token-endpoint response MAY omit refresh_token (meaning "keep the old one"). _store_token_response was storing "" in that case, causing the next expiry to raise "no refresh token" and force a full re-auth. The previous refresh token is now preserved when the response does not supply a new one. Adds a regression test covering the omitted-refresh_token path. Bumps to 0.6.1. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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
refresh_token(meaning "keep the previous one")._store_token_responsewas overwriting it with"", so the second token expiry always raised "no refresh token — run auth-login again" and forced a full re-authentication._store_token_responsenow accepts an optionalprev_tokkwarg and falls back to the old refresh token when the response omits one._refresh_if_neededpassesprev_tok=tokso the fallback is available.SilentRefreshTest::test_refresh_token_preserved_when_response_omits_it.Test plan
uv run pytest tests/ -k SilentRefresh -v— both silent-refresh tests passuv run pytest tests/ -v— all 88 tests green🤖 Generated with Claude Code