{"record":{"id":"7f0a4051cd957f0d","repo":"musistudio/claude-code-router","slug":"new-api-refresh-response-did-not-include-an-access","errorCode":null,"errorMessage":"New API refresh response did not include an access token.","messagePattern":"New API refresh response did not include an access token\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/electron/bundled-plugins/new-api-account/index.cjs","lineNumber":48,"sourceCode":"    throw new Error(\"New API provider base URL is missing.\");\n  }\n\n  const timeoutMs = normalizeTimeoutMs(options.timeoutMs);\n  const requestOrigin = readString(options.requestOrigin) || root;\n  const refreshPayload = await request.fetchProviderAccountJson({\n    body: options.refreshBody ?? {},\n    credentials: \"include\",\n    endpoint: rootUrl(root, readString(options.refreshPath) || DEFAULT_REFRESH_PATH),\n    headers: readStringRecord(options.refreshHeaders),\n    method: \"POST\",\n    requestOrigin,\n    timeoutMs\n  });\n  assertSuccessfulPayload(refreshPayload, \"New API refresh\");\n\n  const token = refreshTokenFromPayload(refreshPayload);\n  if (!token) {\n    throw new Error(\"New API refresh response did not include an access token.\");\n  }\n\n  const subscriptionPayload = await request.fetchProviderAccountJson({\n    credentials: \"omit\",\n    endpoint: rootUrl(root, readString(options.subscriptionPath) || DEFAULT_SUBSCRIPTION_PATH),\n    headers: {\n      ...readStringRecord(options.subscriptionHeaders),\n      authorization: `Bearer ${token}`\n    },\n    method: \"GET\",\n    requestOrigin,\n    timeoutMs\n  });\n  assertSuccessfulPayload(subscriptionPayload, \"New API subscription\");\n\n  const meter = subscriptionQuotaMeter(subscriptionPayload, options);\n  return {\n    message: subscriptionMessage(subscriptionPayload),","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/electron/bundled-plugins/new-api-account/index.cjs#L30-L66","documentation":"After the refresh call succeeds, refreshTokenFromPayload inspects the response for an access token; if none is found the connector cannot authenticate subsequent subscription calls and throws. The expected token location depends on the New API provider's response shape.","triggerScenarios":"Provider returns 200 with a body lacking the token field (expired session, MFA challenge, HTML login page parsed as JSON, or a changed response schema).","commonSituations":"Expired/revoked credentials where the endpoint returns success without a token, provider version changed token field name, cookie-based auth not attached, or a proxy/CDN intercepting with an HTML error page.","solutions":["Re-authenticate/renew the stored provider account credentials and retry","Inspect the raw refresh response body to find where the token actually lives and update refreshTokenFromPayload mapping/options","Confirm the refresh endpoint and refreshBody in options match the provider's API","Check for proxy/SSO interception returning non-JSON"],"exampleFix":"// before\nconst token = refreshTokenFromPayload(refreshPayload);\nif (!token) throw new Error('New API refresh response did not include an access token.');\n\n// after\nconst token = refreshTokenFromPayload(refreshPayload)\n  ?? readPath(payloadData(refreshPayload), ['data', 'access_token']);\nif (!token) throw new Error('New API refresh response did not include an access token.');","handlingStrategy":"try-catch","validationCode":"const token = refreshTokenFromPayload(refreshPayload);\nif (!token) console.warn('refresh payload keys:', Object.keys(payloadData(refreshPayload)));","typeGuard":"null","tryCatchPattern":"try { token = refreshTokenFromPayload(refreshPayload); } catch { /* never thrown; guard below */ }\nif (!token) { await reauthenticate(); return; }","preventionTips":["Map the provider's documented token field before shipping","Treat missing token as a signal to re-login, not retry","Log payload shape on first integration run"],"tags":["auth","token","refresh","provider-response"],"backgroundTag":"oauth-token-refresh-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}