Skip to content

Commit 4e25534

Browse files
g97iulio1609Copilot
andcommitted
fix: conditionally include client_id for client_secret_post
When client_id is None, omit it from the request body instead of raising an error. This supports edge cases where client_secret_post authentication is used without a registered client_id. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9d28fcb commit 4e25534

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/mcp/client/auth/oauth2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ 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 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
210+
if self.client_info.client_id:
211+
data["client_id"] = self.client_info.client_id
213212
data["client_secret"] = self.client_info.client_secret
214213
# For auth_method == "none", don't add any client_secret
215214

0 commit comments

Comments
 (0)