Skip to content

fix: request JSON token responses#2956

Closed
fengjikui wants to merge 1 commit into
modelcontextprotocol:mainfrom
fengjikui:codex/oauth-token-accept-json
Closed

fix: request JSON token responses#2956
fengjikui wants to merge 1 commit into
modelcontextprotocol:mainfrom
fengjikui:codex/oauth-token-accept-json

Conversation

@fengjikui

Copy link
Copy Markdown

Summary

  • add an Accept: application/json header to OAuth token endpoint requests
  • share the token request headers across authorization-code, refresh, client-credentials, private-key JWT, and JWT bearer grants
  • assert the header in the relevant client auth tests

Fixes #1523.

Validation

  • uv run pytest tests/client/test_auth.py::TestOAuthFallback::test_token_exchange_request_authorization_code tests/client/test_auth.py::TestOAuthFallback::test_refresh_token_request tests/client/auth/extensions/test_client_credentials.py::TestOAuthFlowClientCredentials::test_token_exchange_request_jwt_predefined tests/client/auth/extensions/test_client_credentials.py::TestClientCredentialsOAuthProvider::test_exchange_token_client_credentials tests/client/auth/extensions/test_client_credentials.py::TestPrivateKeyJWTOAuthProvider::test_exchange_token_client_credentials -q
  • uv run ruff format --check src/mcp/client/auth/utils.py src/mcp/client/auth/oauth2.py src/mcp/client/auth/extensions/client_credentials.py tests/client/test_auth.py tests/client/auth/extensions/test_client_credentials.py
  • uv run ruff check src/mcp/client/auth/utils.py src/mcp/client/auth/oauth2.py src/mcp/client/auth/extensions/client_credentials.py tests/client/test_auth.py tests/client/auth/extensions/test_client_credentials.py
  • uv run pyright src/mcp/client/auth/utils.py src/mcp/client/auth/oauth2.py src/mcp/client/auth/extensions/client_credentials.py tests/client/test_auth.py tests/client/auth/extensions/test_client_credentials.py
  • uv run pytest tests/client/test_auth.py tests/client/auth/extensions/test_client_credentials.py -q

@maxisbey maxisbey closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuthClientProvider._handle_token_response expect json

2 participants