Skip to content

mcp: handle oauth2.RetrieveError in client authorization retry logic#909

Open
smlx wants to merge 1 commit intomodelcontextprotocol:mainfrom
smlx:retry-retrieve-error
Open

mcp: handle oauth2.RetrieveError in client authorization retry logic#909
smlx wants to merge 1 commit intomodelcontextprotocol:mainfrom
smlx:retry-retrieve-error

Conversation

@smlx
Copy link
Copy Markdown

@smlx smlx commented Apr 25, 2026

Previously, an expired refresh token in the oauth2.Token returned from OAuthHandler.TokenSource() would cause the connection to fail.

From the client perspective, this meant that the MCP connection was in a hard-failed state with no way to re-authorize.

The change in this commit causes Authorize() to be called in the event of both an oauth2.RetrieveError, as well as in the pre-existing case of a 401/403 HTTP response. Clients will handle this in their existing Authorize() flows to get a new valid token for the connection.

Previously, an expired refresh token in the oauth2.Token returned from
OAuthHandler.TokenSource() would cause the connection to fail.

From the client perspective, this meant that the MCP connection was in a
hard-failed state with no way to re-authorize.

The change in this commit causes Authorize() to be called in the event
of both an oauth2.RetrieveError, as well as in the pre-existing case of
a 401/403 HTTP response. Clients will handle this in their existing
Authorize() flows to get a new valid token for the connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant