earendil-works/pi · error · Error
xAI OAuth device authorization failed (HTTP ${response.statu
Error message
xAI OAuth device authorization failed (HTTP ${response.status})${detail ? `: ${detail}` : ""} What it means
Error "xAI OAuth device authorization failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/auth/oauth/xai.ts:156
type: "oauth",
access,
refresh,
expires: Date.now() + expiresInSeconds * 1000 - REFRESH_SKEW_MS,
};
}
async function requestDeviceCode(signal: AbortSignal): Promise<XaiDeviceCode> {
const response = await postForm(
XAI_DEVICE_CODE_URL,
{
client_id: XAI_CLIENT_ID,
scope: XAI_SCOPE,
referrer: "pi",
},
signal,
);
if (!response.ok) {
throw requestFailure("device authorization", response);
}
return parseDeviceCode(response.body);
}
async function pollForTokens(device: XaiDeviceCode, signal: AbortSignal): Promise<OAuthCredential> {
return pollOAuthDeviceCodeFlow<OAuthCredential>({
intervalSeconds: device.intervalSeconds,
expiresInSeconds: device.expiresInSeconds,
waitBeforeFirstPoll: true,
signal,
poll: async () => {
const response = await postForm(
XAI_TOKEN_URL,
{
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
client_id: XAI_CLIENT_ID,
device_code: device.deviceCode,
},View on GitHub (pinned to 4af9d21d3b)
Solutions
- xAI device authorization failed; retry the OAuth flow and check the HTTP status detail.
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/xai.ts:156 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/323f143d45f29d97.
Report an issue: GitHub.