earendil-works/pi · error · Error
Missing authorization code
Error message
Missing authorization code
What it means
Neither the local callback server nor the manually pasted authorization input produced an authorization code, so the OAuth login cannot proceed to token exchange; usually the user dismissed both flows or pasted an input without a code.
Solutions
- Repeat the login and complete the authorization; the callback lacked a code.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/anthropic.ts:303 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/6c69f27c6144e5a4.
Report an issue: GitHub.
Appendix: source
Thrown at packages/ai/src/auth/oauth/anthropic.ts:303
} else if (manualInput) {
const parsed = parseAuthorizationInput(manualInput);
if (parsed.state && parsed.state !== verifier) throw new Error("OAuth state mismatch");
code = parsed.code;
state = parsed.state ?? verifier;
}
if (!code) {
await manualPromise;
if (manualError) throw manualError;
if (manualInput) {
const parsed = parseAuthorizationInput(manualInput);
if (parsed.state && parsed.state !== verifier) throw new Error("OAuth state mismatch");
code = parsed.code;
state = parsed.state ?? verifier;
}
}
if (!code) throw new Error("Missing authorization code");
if (!state) throw new Error("Missing OAuth state");
interaction.notify({ type: "progress", message: "Exchanging authorization code for tokens..." });
return exchangeAuthorizationCode(code, state, verifier, REDIRECT_URI, interaction.signal);
} finally {
interaction.signal.removeEventListener("abort", onAbort);
manualAbort.abort();
server.server.close();
}
}
/**
* Refresh Anthropic OAuth token
*/
async function refreshAnthropicToken(refreshToken: string, signal: AbortSignal): Promise<OAuthCredential> {
let responseBody: string;
try {
responseBody = await postJson(
TOKEN_URL,View on GitHub (pinned to 4af9d21d3b)