Skip to content

Commit 6246f6a

Browse files
committed
Set a preferred auth method on the client registration
1 parent 9f6e731 commit 6246f6a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

client/src/lib/oauth-state-machine.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { OAuthStep, AuthDebuggerState } from "./auth-types";
2-
import { DebugInspectorOAuthClientProvider } from "./auth";
31
import {
42
discoverOAuthMetadata,
5-
registerClient,
6-
startAuthorization,
7-
exchangeAuthorization,
83
discoverOAuthProtectedResourceMetadata,
4+
exchangeAuthorization,
5+
registerClient,
96
selectResourceURL,
7+
startAuthorization,
108
} from "@modelcontextprotocol/sdk/client/auth.js";
119
import {
1210
OAuthMetadataSchema,
1311
OAuthProtectedResourceMetadata,
1412
} from "@modelcontextprotocol/sdk/shared/auth.js";
13+
import { DebugInspectorOAuthClientProvider } from "./auth";
14+
import { AuthDebuggerState, OAuthStep } from "./auth-types";
1515

1616
export interface StateMachineContext {
1717
state: AuthDebuggerState;
@@ -88,6 +88,16 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
8888
clientMetadata.scope = scopesSupported.join(" ");
8989
}
9090

91+
// Select a preferred auth method
92+
const authMethodsSupported =
93+
metadata.token_endpoint_auth_methods_supported;
94+
for (const authMethod of ["client_secret_basic", "client_secret_post"]) {
95+
if (authMethodsSupported && authMethodsSupported.includes(authMethod)) {
96+
clientMetadata.token_endpoint_auth_method = authMethod;
97+
break;
98+
}
99+
}
100+
91101
const fullInformation = await registerClient(context.serverUrl, {
92102
metadata,
93103
clientMetadata,

0 commit comments

Comments
 (0)