|
19 | 19 | import httpx |
20 | 20 | from pydantic import BaseModel, Field, ValidationError |
21 | 21 |
|
22 | | -from mcp.client.auth.exceptions import OAuthFlowError, OAuthRegistrationError, OAuthTokenError |
| 22 | +from mcp.client.auth.exceptions import OAuthFlowError, OAuthTokenError |
23 | 23 | from mcp.client.auth.utils import ( |
24 | 24 | build_oauth_authorization_server_metadata_discovery_urls, |
25 | 25 | build_protected_resource_metadata_discovery_urls, |
@@ -299,44 +299,6 @@ async def _handle_protected_resource_response(self, response: httpx.Response) -> |
299 | 299 | f"Protected Resource Metadata request failed: {response.status_code}" |
300 | 300 | ) # pragma: no cover |
301 | 301 |
|
302 | | - async def _register_client(self) -> httpx.Request | None: |
303 | | - """Build registration request or skip if already registered.""" |
304 | | - if self.context.client_info: |
305 | | - return None |
306 | | - |
307 | | - if self.context.oauth_metadata and self.context.oauth_metadata.registration_endpoint: |
308 | | - registration_url = str(self.context.oauth_metadata.registration_endpoint) # pragma: no cover |
309 | | - else: |
310 | | - auth_base_url = self.context.get_authorization_base_url(self.context.server_url) |
311 | | - registration_url = urljoin(auth_base_url, "/register") |
312 | | - |
313 | | - registration_data = self.context.client_metadata.model_dump(by_alias=True, mode="json", exclude_none=True) |
314 | | - |
315 | | - # If token_endpoint_auth_method is None, auto-select based on server support |
316 | | - if self.context.client_metadata.token_endpoint_auth_method is None: |
317 | | - preference_order = ["client_secret_basic", "client_secret_post", "none"] |
318 | | - |
319 | | - if self.context.oauth_metadata and self.context.oauth_metadata.token_endpoint_auth_methods_supported: |
320 | | - supported = self.context.oauth_metadata.token_endpoint_auth_methods_supported |
321 | | - for method in preference_order: |
322 | | - if method in supported: |
323 | | - registration_data["token_endpoint_auth_method"] = method |
324 | | - break |
325 | | - else: |
326 | | - # No compatible methods between client and server |
327 | | - raise OAuthRegistrationError( |
328 | | - f"No compatible authentication methods. " |
329 | | - f"Server supports: {supported}, " |
330 | | - f"Client supports: {preference_order}" |
331 | | - ) |
332 | | - else: |
333 | | - # No server metadata available, use our default preference |
334 | | - registration_data["token_endpoint_auth_method"] = preference_order[0] |
335 | | - |
336 | | - return httpx.Request( |
337 | | - "POST", registration_url, json=registration_data, headers={"Content-Type": "application/json"} |
338 | | - ) |
339 | | - |
340 | 302 | async def _perform_authorization(self) -> httpx.Request: |
341 | 303 | """Perform the authorization flow.""" |
342 | 304 | auth_code, code_verifier = await self._perform_authorization_code_grant() |
|
0 commit comments