{"record":{"id":"f484afdcf05e2bf3","repo":"diegosouzapw/OmniRoute","slug":"access-token-missing","errorCode":"access_token_missing","errorMessage":"Claude connection is missing access_token. Refresh or re-authenticate this account first.","messagePattern":"Claude connection is missing access_token\\. Refresh or re-authenticate this account first\\.","errorType":"exception","errorClass":"ClaudeAuthFileError","httpStatus":409,"severity":"error","filePath":"src/lib/oauth/utils/claudeAuthFile.ts","lineNumber":127,"sourceCode":"\n  return normalized || \"account\";\n}\n\nexport function extractClaudeEmail(connection: ClaudeConnectionLike): string | null {\n  const psd = toRecord(connection.providerSpecificData);\n  return (\n    toNonEmptyString(psd.bootstrapEmail) ||\n    toNonEmptyString(connection.email) ||\n    toNonEmptyString(connection.displayName)\n  );\n}\n\nexport function buildClaudeAuthPayload(connection: ClaudeConnectionLike): ClaudeAuthFilePayload {\n  const accessToken = toNonEmptyString(connection.accessToken);\n  const refreshToken = toNonEmptyString(connection.refreshToken);\n\n  if (!accessToken) {\n    throw new ClaudeAuthFileError(\n      \"Claude connection is missing access_token. Refresh or re-authenticate this account first.\",\n      409,\n      \"access_token_missing\"\n    );\n  }\n\n  if (!refreshToken) {\n    throw new ClaudeAuthFileError(\n      \"Claude connection is missing refresh_token. Re-authenticate this account before exporting.\",\n      409,\n      \"reauth_required\"\n    );\n  }\n\n  // expiresAt in DB is ISO string; the file format expects ms epoch\n  const expiresAtMs = connection.expiresAt ? new Date(connection.expiresAt).getTime() : 0;\n\n  const psd = toRecord(connection.providerSpecificData);","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/utils/claudeAuthFile.ts#L109-L145","documentation":"buildClaudeAuthPayload guard: the Claude connection being exported has no non-empty accessToken. Because the payload for credentials.json requires valid tokens, the 409 access_token_missing error tells the caller to refresh or re-authenticate first (a refresh is normally attempted by resolveFreshClaudeConnection before this point, so reaching here means refresh did not yield a token).","triggerScenarios":"Thrown at src/lib/oauth/utils/claudeAuthFile.ts:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Trigger a token refresh for the connection and retry the export","If refresh fails with invalid_grant, re-authenticate the Claude account (new OAuth flow)","Check the connection row was not corrupted (accessToken nulled) in the DB"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}