Skip to content

Commit 3c482be

Browse files
committed
fix: accept HTTP 201 status code in token exchange
Fixes #1502 Some OAuth servers (like Supabase) return 201 Created instead of 200 OK for successful token exchanges. The OAuth 2.0 spec doesn't mandate a specific success status code, so we should accept both 200 and 201.
1 parent 1200ba0 commit 3c482be

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mcp/client/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ async def _exchange_token(self, auth_code: str, code_verifier: str) -> httpx.Req
429429

430430
async def _handle_token_response(self, response: httpx.Response) -> None:
431431
"""Handle token exchange response."""
432-
if response.status_code != 200:
432+
if response.status_code != 200 and response.status_code != 201:
433433
raise OAuthTokenError(f"Token exchange failed: {response.status_code}")
434434

435435
try:

0 commit comments

Comments
 (0)