diegosouzapw/OmniRoute · error

No JSON found in decoded code

Error message

No JSON found in decoded code

What it means

Cline exchangeToken(): the auth code was decoded from base64 (after URI decoding and padding restoration) but contains no '{...}' JSON — the pasted code is not a Cline-embedded token blob, so the fallback remote exchange path cannot parse it either.

Solutions

  1. Copy the complete code from the callback URL
  2. Fall back to the tokenExchangeUrl HTTP path for non-embedded codes
Defensive patterns

Strategy: fallback

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.

Appendix: 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)