pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/modelcontextprotocol/python-sdk/pull/2699

/actions-9111c292f95f2fb0.css" /> fix(auth): add Accept header to token and refresh requests by william-xue · Pull Request #2699 · modelcontextprotocol/python-sdk · GitHub
Skip to content

fix(auth): add Accept header to token and refresh requests#2699

Open
william-xue wants to merge 1 commit into
modelcontextprotocol:mainfrom
william-xue:fix/auth-accept-json-header
Open

fix(auth): add Accept header to token and refresh requests#2699
william-xue wants to merge 1 commit into
modelcontextprotocol:mainfrom
william-xue:fix/auth-accept-json-header

Conversation

@william-xue
Copy link
Copy Markdown

Summary

OAuth token and refresh requests do not include an Accept: application/json header. Servers that default to form-encoded responses (e.g. GitHub's OAuth token endpoint) will not return JSON, causing handle_token_response_scopes to fail with a parse error.

This adds Accept: application/json to both _build_token_request and _refresh_token so servers know to respond with JSON.

Fixes #1523

Test plan

  • Added Accept header assertions to existing test_token_exchange_request_authorization_code and test_refresh_token_request tests
  • All 96 existing auth tests pass: uv run --frozen pytest tests/client/test_auth.py

Risk

Minimal — only adds a standard HTTP header to outgoing requests. No behavioral change for servers already returning JSON.

OAuthClientProvider._build_token_request and _refresh_token did not
include an Accept header, so servers that default to form-encoded
responses (e.g. GitHub's OAuth token endpoint) would not return JSON.
This caused token exchange to fail with a parse error.

Added Accept: application/json to both token exchange and refresh
requests so servers know to respond with JSON.
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

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy