fix: OAuth 2.1 (Static) MCP connections send no client secret to servers like X Ads (#32818)

With OAuth 2.1 (Static), when the authorization server did not accept the client secret as a form field, Open WebUI used whichever auth method the server's metadata listed first. X Ads lists "none" (public client, no secret) first, so the token exchange went out without the configured client secret and X rejected it with "Missing valid authorization header". When the server supports HTTP Basic auth, the secret is now sent that way, no matter which method it lists first.

Fixes #32813
This commit is contained in:
Classic298 2026-10-21 09:38:34 +02:00 • committed by GitHub
parent 7909f2bb99
commit 21f770fb73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -714,7 +714,11 @@ async def get_oauth_client_info_with_static_credentials(
oauth_server_metadata.token_endpoint_auth_methods_supported
and token_endpoint_auth_method not in oauth_server_metadata.token_endpoint_auth_methods_supported
):
token_endpoint_auth_method = oauth_server_metadata.token_endpoint_auth_methods_supported[0]
# List order is no preference; prefer a method that sends the secret
if 'client_secret_basic' in oauth_server_metadata.token_endpoint_auth_methods_supported:
token_endpoint_auth_method = 'client_secret_basic'
else:
token_endpoint_auth_method = oauth_server_metadata.token_endpoint_auth_methods_supported[0]
oauth_client_info = OAuthClientInformationFull(
client_id=oauth_client_id,