Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

fix: accept HTTP 200 status in OAuth pre-flight check (#1874)

Jeremiah Lowin0ee263a1c6a8
diff --git a/src/fastmcp/client/auth/oauth.py b/src/fastmcp/client/auth/oauth.py
index 18c4cb1b6..e47ab7778 100644
--- a/src/fastmcp/client/auth/oauth.py
+++ b/src/fastmcp/client/auth/oauth.py
@@ -318,8 +318,8 @@ class OAuth(OAuthClientProvider):
"OAuth client not found - cached credentials may be stale"
)
- # For any non-redirect response, something is wrong
- if response.status_code not in (302, 303, 307, 308):
+ # OAuth typically returns redirects, but some providers return 200 with HTML login pages
+ if response.status_code not in (200, 302, 303, 307, 308):
raise RuntimeError(
f"Unexpected authorization response: {response.status_code}"
)