continuedev/continue · critical · Error

Error getting access token: + JSON.stringify(data)

Error message

Error getting access token:  + JSON.stringify(data)

What it means

AskSage's token endpoint returned a non-200 status payload when exchanging email+api_key for an access_token. The adapter throws with the full JSON response so the status/message fields are visible. The credentials were rejected or the token service is unavailable.

Source

Thrown at packages/openai-adapters/src/apis/AskSage.ts:93

        "AskSage adapter: missing apiKey. Provide it in your configuration.",
      );
    }

    // If no email, use API key directly
    if (!this.email || this.email.length === 0) {
      return this.apiKey;
    }

    const url = this.userApiUrl.replace(/\/$/, "") + "/get-token-with-api-key";
    const res = await this.fetchFn(url, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ email: this.email, api_key: this.apiKey }),
    });

    const data = (await res.json()) as AskSageTokenResponse;
    if (parseInt(String(data.status)) !== 200) {
      throw new Error("Error getting access token: " + JSON.stringify(data));
    }
    return data.response.access_token;
  }

  /**
   * Get cached token or refresh if expired
   */
  private async getToken(): Promise<string> {
    if (
      !this.sessionTokenPromise ||
      Date.now() - this.tokenTimestamp > TOKEN_TTL
    ) {
      this.sessionTokenPromise = this.getSessionToken();
      this.tokenTimestamp = Date.now();
      // Clear cache on failure so transient errors don't prevent retries
      this.sessionTokenPromise.catch(() => {
        this.clearTokenCache();
      });

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Verify the apiKey and email pair against the AskSage dashboard
  2. Regenerate the API key if revoked or expired
  3. Check the JSON in the error message for the exact status/message; 5xx means retry later
  4. If using apiKey-only auth, omit email so the key is used directly

Example fix

// before
const api = new AskSage({ apiKey: KEY, email: 'wrong@ex.com' });

// after
const api = new AskSage({ apiKey: KEY }); // or email that matches the key's account
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: verify creds by hitting the token endpoint once at startup
const res = await fetch(TOKEN_URL, { method: 'POST', body: JSON.stringify({ email, api_key }) });
if (!res.ok) throw new Error('AskSage credentials invalid');

Try / catch

try { await api.chatCompletionNonStream(body, signal); }
catch (e) { if (/Error getting access token/.test(String(e))) { /* fix creds; do NOT blind-retry */ throw e; } throw e; }

Prevention

When it happens

Trigger: Calling AskSage chat with email+apiKey configured; the POST to the token endpoint returns {status: 401/403/500,...} — invalid key, wrong email, expired key, or service outage.

Common situations: Revoked or mistyped AskSage API key; email not matching the account that owns the key; AskSage auth service downtime or changed response schema (status no longer numeric 200).

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/11a8a1851dcf7732. Report an issue: GitHub.