diegosouzapw/OmniRoute · error

No JSON found in decoded code

Error message

No JSON found in decoded code

What it means

Error "No JSON found in decoded code" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/oauth/providers/cline.ts:31

  },
  exchangeToken: async (config, code, redirectUri) => {
    try {
      // Cline embeds tokens as base64-encoded JSON in the auth code.
      // The code may be URL-encoded when pasted from the callback URL.
      let base64 = code;
      try {
        base64 = decodeURIComponent(base64);
      } catch {
        /* already decoded */
      }
      const padding = 4 - (base64.length % 4);
      if (padding !== 4) {
        base64 += "=".repeat(padding);
      }
      const decoded = Buffer.from(base64, "base64").toString("utf-8");
      const lastBrace = decoded.lastIndexOf("}");
      if (lastBrace === -1) {
        throw new Error("No JSON found in decoded code");
      }
      const jsonStr = decoded.substring(0, lastBrace + 1);
      const tokenData = JSON.parse(jsonStr);
      return {
        access_token: tokenData.accessToken,
        refresh_token: tokenData.refreshToken,
        email: tokenData.email,
        firstName: tokenData.firstName,
        lastName: tokenData.lastName,
        expires_at: tokenData.expiresAt,
      };
    } catch (e) {
      const response = await fetch(config.tokenExchangeUrl, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Accept: "application/json",
        },

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/oauth/providers/cline.ts:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/6fdb02fa4a96d9cb. Report an issue: GitHub.