decolua/9router · error · Error

No GitHub access token available. Please re-authorize the co

Error message

No GitHub access token available. Please re-authorize the connection.

What it means

getGitHubUsage requires a GitHub OAuth accessToken (not the short-lived copilotToken) to call the copilot_internal/user usage API. The library throws this guard error immediately when the accessToken argument is falsy, before any network call. It signals that the stored GitHub Copilot credential is missing or has not been re-authorized.

Source

Thrown at open-sse/services/usage/github.js:22

import { proxyAwareFetch } from "../../utils/proxyFetch.js";
import { PROVIDER_OAUTH } from "../../providers/index.js";
import { U, parseResetTime } from "./shared.js";

// GitHub API config — single source from registry oauth block
const GITHUB_CONFIG = {
  apiVersion: PROVIDER_OAUTH.github?.apiVersion,
  userAgent: PROVIDER_OAUTH.github?.userAgent,
};

/**
 * GitHub Copilot Usage
 * Uses GitHub accessToken (not copilotToken) to call copilot_internal/user API
 */
export async function getGitHubUsage(accessToken, providerSpecificData, proxyOptions = null) {
  try {
    if (!accessToken) {
      throw new Error("No GitHub access token available. Please re-authorize the connection.");
    }

    // copilot_internal/user API requires GitHub OAuth token, not copilotToken
    const response = await proxyAwareFetch(U("github").url, {
      headers: {
        "Authorization": `token ${accessToken}`,
        "Accept": "application/json",
        "X-GitHub-Api-Version": GITHUB_CONFIG.apiVersion,
        "User-Agent": GITHUB_CONFIG.userAgent,
        "Editor-Version": "vscode/1.100.0",
        "Editor-Plugin-Version": "copilot-chat/0.26.7",
      },
    }, proxyOptions);

    if (!response.ok) {
      const error = await response.text();
      throw new Error(`GitHub API error: ${error}`);
    }

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Re-run the GitHub Copilot OAuth flow so a fresh accessToken is stored on the account
  2. Verify you are passing account.accessToken, not account.copilotToken, to getGitHubUsage
  3. Check the stored provider/account record for an empty or missing accessToken field and populate it
  4. If the token was revoked on GitHub, re-authorize the connection in the dashboard

Example fix

// before
const usage = await getGitHubUsage(account.copilotToken, data, proxyOptions);
// after
const usage = await getGitHubUsage(account.accessToken, data, proxyOptions);
Defensive patterns

Strategy: validation

Validate before calling

if (!account?.accessToken) throw new Error("GitHub Copilot must be re-authorized: no accessToken stored");
await getGitHubUsage(account.accessToken, account.providerSpecificData, proxyOptions);

Type guard

function hasGitHubToken(a) { return typeof a?.accessToken === "string" && a.accessToken.length > 0; }

Try / catch

try {
  usage = await getGitHubUsage(account.accessToken, data, proxy);
} catch (e) {
  if (/No GitHub access token/.test(e.message)) return { reconnect: true };
  throw e;
}

Prevention

When it happens

Trigger: Calling getGitHubUsage (directly or through USAGE_HANDLERS) with accessToken = null/undefined/empty string — typically because the account record has no accessToken field, or OAuth re-auth never stored the token.

Common situations: Copilot OAuth flow was completed for a copilotToken but the durable accessToken was never saved; the account was created by token import without a GitHub token; a re-authorization was revoked or expired and cleared; passing the wrong credential field (copilotToken instead of accessToken).

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/113a6d993610c5b2. Report an issue: GitHub.