{"record":{"id":"113a6d993610c5b2","repo":"decolua/9router","slug":"no-github-access-token-available-please-re-author","errorCode":null,"errorMessage":"No GitHub access token available. Please re-authorize the connection.","messagePattern":"No GitHub access token available\\. Please re-authorize the connection\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/services/usage/github.js","lineNumber":22,"sourceCode":"\nimport { proxyAwareFetch } from \"../../utils/proxyFetch.js\";\nimport { PROVIDER_OAUTH } from \"../../providers/index.js\";\nimport { U, parseResetTime } from \"./shared.js\";\n\n// GitHub API config — single source from registry oauth block\nconst GITHUB_CONFIG = {\n  apiVersion: PROVIDER_OAUTH.github?.apiVersion,\n  userAgent: PROVIDER_OAUTH.github?.userAgent,\n};\n\n/**\n * GitHub Copilot Usage\n * Uses GitHub accessToken (not copilotToken) to call copilot_internal/user API\n */\nexport async function getGitHubUsage(accessToken, providerSpecificData, proxyOptions = null) {\n  try {\n    if (!accessToken) {\n      throw new Error(\"No GitHub access token available. Please re-authorize the connection.\");\n    }\n\n    // copilot_internal/user API requires GitHub OAuth token, not copilotToken\n    const response = await proxyAwareFetch(U(\"github\").url, {\n      headers: {\n        \"Authorization\": `token ${accessToken}`,\n        \"Accept\": \"application/json\",\n        \"X-GitHub-Api-Version\": GITHUB_CONFIG.apiVersion,\n        \"User-Agent\": GITHUB_CONFIG.userAgent,\n        \"Editor-Version\": \"vscode/1.100.0\",\n        \"Editor-Plugin-Version\": \"copilot-chat/0.26.7\",\n      },\n    }, proxyOptions);\n\n    if (!response.ok) {\n      const error = await response.text();\n      throw new Error(`GitHub API error: ${error}`);\n    }","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/services/usage/github.js#L4-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Re-run the GitHub Copilot OAuth flow so a fresh accessToken is stored on the account","Verify you are passing account.accessToken, not account.copilotToken, to getGitHubUsage","Check the stored provider/account record for an empty or missing accessToken field and populate it","If the token was revoked on GitHub, re-authorize the connection in the dashboard"],"exampleFix":"// before\nconst usage = await getGitHubUsage(account.copilotToken, data, proxyOptions);\n// after\nconst usage = await getGitHubUsage(account.accessToken, data, proxyOptions);","handlingStrategy":"validation","validationCode":"if (!account?.accessToken) throw new Error(\"GitHub Copilot must be re-authorized: no accessToken stored\");\nawait getGitHubUsage(account.accessToken, account.providerSpecificData, proxyOptions);","typeGuard":"function hasGitHubToken(a) { return typeof a?.accessToken === \"string\" && a.accessToken.length > 0; }","tryCatchPattern":"try {\n  usage = await getGitHubUsage(account.accessToken, data, proxy);\n} catch (e) {\n  if (/No GitHub access token/.test(e.message)) return { reconnect: true };\n  throw e;\n}","preventionTips":["Persist accessToken (not just copilotToken) during OAuth","Check token presence before rendering usage panels","Prompt re-authorization whenever the token field is empty","Never pass the short-lived copilotToken as accessToken"],"tags":["auth","oauth","github-copilot","missing-token"],"backgroundTag":"missing-oauth-access-token","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}