fix(auth): distinguish rejected refresh tokens from transient failures#963
Open
stevenlee-oai wants to merge 1 commit into
Open
Conversation
DaleSeo
reviewed
Jul 7, 2026
DaleSeo
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution, @stevenlee-oai. I have a quick comment and we should address the linting errors to merge this.
| /// Get access token from local credential store. | ||
| /// If expired, refresh it automatically when a refresh token is available. | ||
| /// When the access token has expired and no refresh token is available (or | ||
| /// the refresh itself fails), returns [`AuthError::AuthorizationRequired`] |
Member
There was a problem hiding this comment.
Can we update this public doc about the new error?
Member
|
@stevenlee-oai The linting errors will be gone once you rebase! |
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
AuthError::TokenRefreshFailed(String)currently combines definitive OAuth refresh-token rejection with transient request, parse, and provider failures.try_refresh_or_reauth()then maps the whole variant toAuthorizationRequired, so a temporary provider failure can incorrectly prompt users to sign in again.This change:
TokenRefreshRejectedfor OAuthinvalid_grant;AuthorizationRequiredandTokenRefreshRejectedto reauthorization;temporarily_unavailable, transport, parse, and other failures as retryableTokenRefreshFailed;AuthorizationRequireddirectly when no refresh token exists.Tests
cargo test -p rmcp --all-features invalid_grant_refresh_requires_reauthorizationcargo test -p rmcp --all-features temporary_refresh_failure_does_not_require_reauthorizationcargo test -p rmcp --all-features refresh_token_returns_error_when_no_refresh_tokencargo clippy -p rmcp --all-features --lib --testsThe three focused tests pass. Clippy passes with two pre-existing
sse_stream::from_byte_streamdeprecation warnings.