diegosouzapw/OmniRoute · error · ClaudeAuthFileError

access_token_missing

access_token_missing

Error message

Claude connection is missing access_token. Refresh or re-authenticate this account first.

What it means

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).

Solutions

  1. Trigger a token refresh for the connection and retry the export
  2. If refresh fails with invalid_grant, re-authenticate the Claude account (new OAuth flow)
  3. Check the connection row was not corrupted (accessToken nulled) in the DB
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/oauth/utils/claudeAuthFile.ts:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/f484afdcf05e2bf3. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/oauth/utils/claudeAuthFile.ts:127

  return normalized || "account";
}

export function extractClaudeEmail(connection: ClaudeConnectionLike): string | null {
  const psd = toRecord(connection.providerSpecificData);
  return (
    toNonEmptyString(psd.bootstrapEmail) ||
    toNonEmptyString(connection.email) ||
    toNonEmptyString(connection.displayName)
  );
}

export function buildClaudeAuthPayload(connection: ClaudeConnectionLike): ClaudeAuthFilePayload {
  const accessToken = toNonEmptyString(connection.accessToken);
  const refreshToken = toNonEmptyString(connection.refreshToken);

  if (!accessToken) {
    throw new ClaudeAuthFileError(
      "Claude connection is missing access_token. Refresh or re-authenticate this account first.",
      409,
      "access_token_missing"
    );
  }

  if (!refreshToken) {
    throw new ClaudeAuthFileError(
      "Claude connection is missing refresh_token. Re-authenticate this account before exporting.",
      409,
      "reauth_required"
    );
  }

  // expiresAt in DB is ISO string; the file format expects ms epoch
  const expiresAtMs = connection.expiresAt ? new Date(connection.expiresAt).getTime() : 0;

  const psd = toRecord(connection.providerSpecificData);

View on GitHub (pinned to a179ffed5b)