earendil-works/pi · error · Error
Failed to extract accountId from token
Error message
Failed to extract accountId from token
What it means
Error "Failed to extract accountId from token" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/auth/oauth/openai-codex.ts:406
},
cancelWait: () => {},
waitForCode: async () => null,
});
});
});
}
function getAccountId(accessToken: string): string | null {
const payload = decodeJwt(accessToken);
const auth = payload?.[JWT_CLAIM_PATH];
const accountId = auth?.chatgpt_account_id;
return typeof accountId === "string" && accountId.length > 0 ? accountId : null;
}
function credentialsFromToken(token: OAuthToken): OAuthCredential {
const accountId = getAccountId(token.access);
if (!accountId) {
throw new Error("Failed to extract accountId from token");
}
return {
type: "oauth",
access: token.access,
refresh: token.refresh,
expires: token.expires,
accountId,
};
}
async function exchangeAuthorizationCodeForCredentials(
code: string,
verifier: string,
redirectUri: string,
signal: AbortSignal,
): Promise<OAuthCredential> {
return credentialsFromToken(await exchangeAuthorizationCode(code, verifier, redirectUri, signal));View on GitHub (pinned to 4af9d21d3b)
Solutions
- Re-login; the token does not carry an extractable accountId claim.
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/openai-codex.ts:406 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/0f0ca145baf62b4f.
Report an issue: GitHub.