MCPcopy Index your code
hub / github.com/modelcontextprotocol/typescript-sdk / applyClientAuthentication

Function applyClientAuthentication

src/client/auth.ts:316–337  ·  view source on GitHub ↗

* Applies client authentication to the request based on the specified method. * * Implements OAuth 2.1 client authentication methods: * - client_secret_basic: HTTP Basic authentication (RFC 6749 Section 2.3.1) * - client_secret_post: Credentials in request body (RFC 6749 Section 2.3.1) * - none

(
    method: ClientAuthMethod,
    clientInformation: OAuthClientInformation,
    headers: Headers,
    params: URLSearchParams
)

Source from the content-addressed store, hash-verified

314 * @throws {Error} When required credentials are missing
315 */
316function applyClientAuthentication(
317 method: ClientAuthMethod,
318 clientInformation: OAuthClientInformation,
319 headers: Headers,
320 params: URLSearchParams
321): void {
322 const { client_id, client_secret } = clientInformation;
323
324 switch (method) {
325 case 'client_secret_basic':
326 applyBasicAuth(client_id, client_secret, headers);
327 return;
328 case 'client_secret_post':
329 applyPostAuth(client_id, client_secret, params);
330 return;
331 case 'none':
332 applyPublicAuth(client_id, params);
333 return;
334 default:
335 throw new Error(`Unsupported client authentication method: ${method}`);
336 }
337}
338
339/**
340 * Applies HTTP Basic authentication (RFC 6749 Section 2.3.1)

Callers 1

executeTokenRequestFunction · 0.85

Calls 3

applyBasicAuthFunction · 0.85
applyPostAuthFunction · 0.85
applyPublicAuthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…