Skip to content

OAuth client: refresh before re-authorizing, and discover before refreshing - #3328

Closed
maxisbey wants to merge 5 commits into
mainfrom
oauth-refresh-on-401
Closed

maxisbey wants to merge 5 commits into
mainfrom
oauth-refresh-on-401

OAuth client: refresh before re-authorizing, and discover before refr…

2bc618a
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 18, 2026 in 10m 8s

Code review found 2 new issues (5 earlier findings still open)

Found 8 candidates, confirmed 7: 2 posted in this review, 5 from earlier reviews still open. See review comments for details.

Details

Severity Count
🔴 Important 3
🟡 Nit 4
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/mcp/client/auth/oauth2.py:757 New 401-branch refresh POSTs the stored refresh token to a token endpoint nominated by the (untrusted) resource server f
🔴 Important src/mcp/client/auth/oauth2.py:758 A transient non-200 from the token endpoint during the new 401-branch refresh permanently disables refresh for the proce

Annotations

Check failure on line 757 in src/mcp/client/auth/oauth2.py

See this annotation in the file changed.

@claude claude / Claude Code Review

New 401-branch refresh POSTs the stored refresh token to a token endpoint nominated by the (untrusted) resource server for unstamped/pre-registered and CIMD registrations, since credentials_match_issuer treats them as always matching and never clears… [

New 401-branch refresh POSTs the stored refresh token to a token endpoint nominated by the (untrusted) resource server for unstamped/pre-registered and CIMD registrations, since credentials_match_issuer treats them as always matching and never clears… [additional confirmed claim at this location: The new Step 5 refresh is not gated on discovered metadata: when ASM discovery fails (all well-known URLs 404, or a 5xx breaks the loop) oauth_metadata stays None and _refresh_token() falls back to…

Check failure on line 758 in src/mcp/client/auth/oauth2.py

See this annotation in the file changed.

@claude claude / Claude Code Review

A transient non-200 from the token endpoint during the new 401-branch refresh permanently disables refresh for the process lifetime: the failure path clears in-memory tokens but, unlike the pre-request refresh site (lines 599-601), never resets… [supers

A transient non-200 from the token endpoint during the new 401-branch refresh permanently disables refresh for the process lifetime: the failure path clears in-memory tokens but, unlike the pre-request refresh site (lines 599-601), never resets… [superseded plausible claim at this location: 401-branch refresh-first short-circuits scope escalation: a 401 carrying a WWW-Authenticate scope challenge now gets a same-scope refreshed token instead of the full authorization with the Step 3…]