Initial Checks
Description
ClientAuthenticator behavior is only partially honoring token_endpoint_auth_method="none":
|
if client.client_secret: # pragma: no branch |
|
if not request_client_secret: |
|
raise AuthenticationError("Client secret is required") # pragma: no cover |
Essentially:
token_endpoint_auth_method="none" => skip extracting credentials from the request (correct)
client.client_secret exists => raise error if no credentials were extracted from the request (incorrect)
If token_endpoint_auth_method="none" is set, it should never be checking for a client_secret value on the request, regardless of whether a secret has ever been generated for the client.
Suggested fix is to condition the client.client_secret check on token_endpoint_auth_method not being none:
if token_endpoint_auth_method != "none" and client.client_secret: # pragma: no branch
if not request_client_secret:
raise AuthenticationError("Client secret is required") # pragma: no cover
Example Code
Python & MCP Python SDK
Initial Checks
Description
ClientAuthenticatorbehavior is only partially honoringtoken_endpoint_auth_method="none":python-sdk/src/mcp/server/auth/middleware/client_auth.py
Lines 102 to 104 in 6b69f63
Essentially:
token_endpoint_auth_method="none"=> skip extracting credentials from the request (correct)client.client_secretexists => raise error if no credentials were extracted from the request (incorrect)If
token_endpoint_auth_method="none"is set, it should never be checking for aclient_secretvalue on the request, regardless of whether a secret has ever been generated for the client.Suggested fix is to condition the
client.client_secretcheck ontoken_endpoint_auth_methodnot beingnone:Example Code
Python & MCP Python SDK