Kong/insomnia · error

Authorization code not found

Error message

Authorization code not found

What it means

OAuth result parsing in the MCP provider's redirectToAuthorization: the redirect completed without OAuth error parameters but also without an authorization code, so there is nothing to exchange for tokens. Indicates a malformed provider redirect configuration.

Solutions

  1. Retry the authorization flow
  2. Check the authorization server returned a code in the redirect
  3. Verify redirect URI matches the registered one
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/insomnia/src/main/mcp/oauth-client-provider.ts:191 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/876537528b487185. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia/src/main/mcp/oauth-client-provider.ts:191

    const { relayUrl, decryptOAuthResult } = encryptOAuthUrl(authorizationUrl.toString());
    BrowserWindow.getAllWindows().forEach(window => {
      window.webContents.send('show-oauth-authorization-modal', relayUrl);
    });
    const shouldOpenDefaultBrowser =
      'grantType' in this.authentication && this.authentication.grantType === 'mcp_auth_flow'
        ? !this.authentication.launchBrowserManually
        : true;
    const redirectedResult = await authorizeUserInDefaultBrowser({
      url: relayUrl,
      openDefaultBrowser: shouldOpenDefaultBrowser,
    });
    const redirectedTo = decryptOAuthResult(redirectedResult);
    const redirectParams = Object.fromEntries(new URL(redirectedTo).searchParams);
    const { code: authorizationCode, error, error_description, error_uri } = redirectParams;
    if (error) {
      throw new Error(JSON.stringify({ error, error_description, error_uri }));
    } else if (!authorizationCode) {
      throw new Error('Authorization code not found');
    }
    await this._redirectEndListener?.(authorizationCode);
  }
  onRedirectEnd(listener: (authorizationCode: string) => void) {
    this._redirectEndListener = listener;
    return () => {
      this._redirectEndListener = null;
    };
  }
  async saveCodeVerifier(codeVerifier: string) {
    this._codeVerifier = codeVerifier;
  }
  async codeVerifier() {
    if (!this._codeVerifier) {
      throw new Error('Code verifier not set');
    }
    return this._codeVerifier;
  }

View on GitHub (pinned to d9bb2b0142)