{"record":{"id":"f55fb4b12e7cd649","repo":"Kong/insomnia","slug":"unauthorized","errorCode":null,"errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"exception","errorClass":"UnauthorizedError","httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/main/mcp/transport-streamable-http.ts","lineNumber":264,"sourceCode":"        resourceMetadataUrl,\n        fetchFn: authFetchFn,\n        scope,\n      });\n      // Wait for user to complete authorization in default browser and get authorization code\n      if (authResult === 'REDIRECT') {\n        // Wait for oauth authorization flow to complete in default browser\n        const authorizationCode = await redirectPromise;\n        // Exchange authorization code for tokens\n        authResult = await auth(authProvider, {\n          serverUrl: url,\n          resourceMetadataUrl,\n          scope,\n          authorizationCode,\n          fetchFn: authFetchFn,\n        });\n      }\n      if (authResult !== 'AUTHORIZED') {\n        throw new UnauthorizedError();\n      }\n    } catch (e) {\n      console.error('Authentication failed', e);\n      // Wrap and throw MCPAuthError for better identification, some of the errors thrown by sdk are generic Error which is hard to identify\n      throw new MCPAuthError(e.message || 'Authentication failed', { cause: e });\n    } finally {\n      // Close the oauth authorization modal after authorization is complete\n      BrowserWindow.getAllWindows().forEach(window => {\n        window.webContents.send('hide-oauth-authorization-modal');\n      });\n      // cleanup the oauth client provider listener\n      unsubscribe();\n    }\n    return await wrappedFetch(url, init, context, authProvider, true);\n  }\n  return response;\n};\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/main/mcp/transport-streamable-http.ts#L246-L282","documentation":"Error \"Unauthorized\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/main/mcp/transport-streamable-http.ts:264 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}