BloopAI/vibe-kanban · error · Error
OAuth init failed (${res.status})
Error message
OAuth init failed (${res.status}) What it means
initOAuth starts the web OAuth flow by POSTing to ${API_BASE}/v1/oauth/web/init with the provider, return_to path, and PKCE app_challenge. If the server responds with any non-OK HTTP status, the function throws 'OAuth init failed (<status>)' instead of returning a handoff_id/authorize_url. This indicates the backend refused to create the OAuth handoff session.
Source
Thrown at packages/remote-web/src/shared/lib/api.ts:65
email: string;
};
export async function initOAuth(
provider: OAuthProvider,
returnTo: string,
appChallenge: string,
): Promise<HandoffInitResponse> {
const res = await fetch(`${API_BASE}/v1/oauth/web/init`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
provider,
return_to: returnTo,
app_challenge: appChallenge,
}),
});
if (!res.ok) {
throw new Error(`OAuth init failed (${res.status})`);
}
return res.json();
}
export async function getAuthMethods(): Promise<AuthMethodsResponse> {
const res = await fetch(`${API_BASE}/v1/auth/methods`, {
cache: "no-store",
});
if (!res.ok) {
throw new Error(`Auth methods lookup failed (${res.status})`);
}
return res.json();
}
export async function redeemOAuth(
handoffId: string,
appCode: string,
appVerifier: string,View on GitHub (pinned to 4deb7eca8f)
Solutions
- Check the response status in the error and match it to server logs for /v1/oauth/web/init.
- Verify the server has OAuth provider credentials configured (e.g. GITHUB_CLIENT_ID/SECRET, GOOGLE client env vars).
- Confirm VITE_API_BASE_URL resolves to the correct remote API host that serves /v1/oauth/web/init.
- Ensure the provider argument is one of 'github' | 'google' as defined by OAuthProvider.
- Retry after server deployment/health issues clear (502/503/429 are often transient).
Example fix
// before
const provider = (new URLSearchParams(location.search).get('provider') ?? 'gitlab') as OAuthProvider;
await initOAuth(provider, returnTo, challenge);
// after: only pass supported providers
const raw = new URLSearchParams(location.search).get('provider');
const provider: OAuthProvider = raw === 'google' ? 'google' : 'github';
await initOAuth(provider, returnTo, challenge); Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate before calling initOAuth
const providers: OAuthProvider[] = ['github', 'google'];
if (!providers.includes(provider)) {
throw new Error(`Unsupported OAuth provider: ${provider}`);
}
if (!API_BASE && !location.pathname.startsWith('/')) {
throw new Error('VITE_API_BASE_URL is not configured');
} Type guard
function isHandoffInitResponse(x: unknown): x is { handoff_id: string; authorize_url: string } {
return typeof x === 'object' && x !== null
&& typeof (x as any).handoff_id === 'string'
&& typeof (x as any).authorize_url === 'string';
} Try / catch
let handoff: HandoffInitResponse;
try {
handoff = await initOAuth(provider, returnTo, appChallenge);
} catch (e) {
const status = (e as Error).message.match(/\((\d+)\)/)?.[1];
showError(`Could not start ${provider} sign-in (HTTP ${status ?? 'network'}). Check provider configuration or try again.`);
return;
}
window.location.assign(handoff.authorize_url); Prevention
- Configure OAuth client ID/secret env vars on the remote server before enabling the buttons.
- Only pass 'github' or 'google' as provider values.
- Verify VITE_API_BASE_URL at build/deploy time.
- Monitor /v1/oauth/web/init for 5xx after deploys.
- Disable OAuth buttons while the API health check fails.
When it happens
Trigger: Calling initOAuth(provider, returnTo, appChallenge) where the POST /v1/oauth/web/init request fails: an unsupported/unknown provider value is sent (400/422), the server's OAuth provider credentials are not configured (500), the API base URL is wrong so a proxy returns 404, the server is down/overloaded (502/503), or rate limiting (429).
Common situations: Remote server deployed without GitHub/Google OAuth client ID/secret env vars; VITE_API_BASE_URL pointing at the wrong host so /v1/oauth/web/init 404s; user clicks 'Sign in with GitHub' while the backend is redeploying; provider name typo or new provider not yet supported by the deployed server version.
Related errors
- OAuth redeem failed (${res.status})
- Auth methods lookup failed (${res.status})
- Local login failed (${res.status})
- github token exchange failed: {detail}
- google token exchange failed: {detail}
AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29).
Data as JSON: /api/errors/1375b256d35ff75c.
Report an issue: GitHub.