MCPcopy Create free account
hub / github.com/modelcontextprotocol/inspector / parseOAuthCallbackParams

Function parseOAuthCallbackParams

client/src/utils/oauthUtils.ts:32–54  ·  view source on GitHub ↗
(location: string)

Source from the content-addressed store, hash-verified

30 * @returns Parsed callback parameters with success/error information
31 */
32export const parseOAuthCallbackParams = (location: string): CallbackParams => {
33 const params = new URLSearchParams(location);
34
35 const code = params.get("code");
36 if (code) {
37 return { successful: true, code };
38 }
39
40 const error = params.get("error");
41 const error_description = params.get("error_description");
42 const error_uri = params.get("error_uri");
43
44 if (error) {
45 return { successful: false, error, error_description, error_uri };
46 }
47
48 return {
49 successful: false,
50 error: "invalid_request",
51 error_description: "Missing code or error in response",
52 error_uri: null,
53 };
54};
55
56/**
57 * Generate a random state for the OAuth 2.0 flow.

Callers 4

handleCallbackFunction · 0.90
OAuthDebugCallbackFunction · 0.90
handleCallbackFunction · 0.90
oauthUtils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected