|
1 | 1 | import { randomBytes } from 'crypto';
|
2 | 2 | import { logger } from '@librechat/data-schemas';
|
3 | 3 | import {
|
4 |
| - discoverOAuthMetadata, |
5 | 4 | registerClient,
|
6 | 5 | startAuthorization,
|
7 | 6 | exchangeAuthorization,
|
| 7 | + discoverAuthorizationServerMetadata, |
8 | 8 | discoverOAuthProtectedResourceMetadata,
|
9 | 9 | } from '@modelcontextprotocol/sdk/client/auth.js';
|
10 | 10 | import { OAuthMetadataSchema } from '@modelcontextprotocol/sdk/shared/auth.js';
|
@@ -61,7 +61,7 @@ export class MCPOAuthHandler {
|
61 | 61 |
|
62 | 62 | // Discover OAuth metadata
|
63 | 63 | logger.debug(`[MCPOAuth] Discovering OAuth metadata from ${authServerUrl}`);
|
64 |
| - const rawMetadata = await discoverOAuthMetadata(authServerUrl); |
| 64 | + const rawMetadata = await discoverAuthorizationServerMetadata(authServerUrl); |
65 | 65 |
|
66 | 66 | if (!rawMetadata) {
|
67 | 67 | logger.error(`[MCPOAuth] Failed to discover OAuth metadata from ${authServerUrl}`);
|
@@ -466,7 +466,10 @@ export class MCPOAuthHandler {
|
466 | 466 | throw new Error('No token URL available for refresh');
|
467 | 467 | } else {
|
468 | 468 | /** Auto-discover OAuth configuration for refresh */
|
469 |
| - const { metadata: oauthMetadata } = await this.discoverMetadata(metadata.serverUrl); |
| 469 | + const oauthMetadata = await discoverAuthorizationServerMetadata(metadata.serverUrl); |
| 470 | + if (!oauthMetadata) { |
| 471 | + throw new Error('Failed to discover OAuth metadata for token refresh'); |
| 472 | + } |
470 | 473 | if (!oauthMetadata.token_endpoint) {
|
471 | 474 | throw new Error('No token endpoint found in OAuth metadata');
|
472 | 475 | }
|
@@ -584,7 +587,7 @@ export class MCPOAuthHandler {
|
584 | 587 | }
|
585 | 588 |
|
586 | 589 | /** Auto-discover OAuth configuration for refresh */
|
587 |
| - const { metadata: oauthMetadata } = await this.discoverMetadata(metadata.serverUrl); |
| 590 | + const oauthMetadata = await discoverAuthorizationServerMetadata(metadata.serverUrl); |
588 | 591 |
|
589 | 592 | if (!oauthMetadata.token_endpoint) {
|
590 | 593 | throw new Error('No token endpoint found in OAuth metadata');
|
|
0 commit comments