Skip to content

Commit 9d28fcb

Browse files
g97iulio1609Copilot
andcommitted
fix: require client_id for client_secret_post auth method
RFC 6749 §2.3.1 requires both client_id and client_secret in the request body for client_secret_post. Raise OAuthFlowError when client_id is missing instead of silently skipping it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7c6aea1 commit 9d28fcb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mcp/client/auth/oauth2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ def prepare_token_auth(
207207
data = {k: v for k, v in data.items() if k != "client_secret"}
208208
elif auth_method == "client_secret_post" and self.client_info.client_secret:
209209
# Include client_id and client_secret in request body (RFC 6749 §2.3.1)
210-
if self.client_info.client_id is not None:
211-
data["client_id"] = self.client_info.client_id
210+
if not self.client_info.client_id:
211+
raise OAuthFlowError("client_id is required for client_secret_post authentication")
212+
data["client_id"] = self.client_info.client_id
212213
data["client_secret"] = self.client_info.client_secret
213214
# For auth_method == "none", don't add any client_secret
214215

0 commit comments

Comments
 (0)