Skip to content

Commit f98a32a

Browse files
committed
- add client id when exchanging token
- initialize provider in test_exchange_token_client_credentials and test_exchange_token_without_scopes unittests
1 parent 1ef124e commit f98a32a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/mcp/client/auth/extensions/client_credentials.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async def _exchange_token_client_credentials(self) -> httpx.Request:
9090
"""Build token exchange request for client_credentials grant."""
9191
token_data: dict[str, Any] = {
9292
"grant_type": "client_credentials",
93+
"client_id": self.context.client_info.client_id,
9394
}
9495

9596
headers: dict[str, str] = {"Content-Type": "application/x-www-form-urlencoded"}

tests/client/auth/extensions/test_client_credentials.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ async def test_exchange_token_client_credentials(self, mock_storage: MockTokenSt
243243
)
244244
provider.context.protocol_version = "2025-06-18"
245245

246+
# Initialize the provider first
247+
await provider._initialize()
248+
246249
request = await provider._perform_authorization()
247250

248251
assert request.method == "POST"
@@ -269,6 +272,9 @@ async def test_exchange_token_without_scopes(self, mock_storage: MockTokenStorag
269272
)
270273
provider.context.protocol_version = "2024-11-05" # Old version - no resource param
271274

275+
# Initialize the provider first
276+
await provider._initialize()
277+
272278
request = await provider._perform_authorization()
273279

274280
content = urllib.parse.unquote_plus(request.content.decode())

0 commit comments

Comments
 (0)