can1357/oh-my-pi · error · AIError.ConfigurationError

Unknown OAuth provider: ${provider}

Error message

Unknown OAuth provider: ${provider}

What it means

loginOAuth resolves the provider against the built-in provider registry (getProviderDefinition) and then runtime-registered extension providers (getOAuthProvider). If neither exists, or the definition has no login implementation, the provider is unknown/not login-capable and the library throws ConfigurationError.

Source

Thrown at packages/ai/src/auth-storage.ts:2985

			/** onPrompt is required for some providers (github-copilot, openai-codex) */
			onPrompt: (prompt: { message: string; placeholder?: string }) => Promise<string>;
		},
	): Promise<OAuthLoginIdentity | undefined> {
		// Only paste-code providers (fixed non-loopback redirect, e.g. GitLab Duo
		// Agent's vscode:// URI) get a default manual-code prompt. For loopback OAuth
		// providers the `OAuthCallbackFlow` would otherwise race this readline prompt
		// against the HTTP callback and, when the callback wins, leave the prompt
		// outstanding — a dirty/blocked terminal. Synthesizing the default only for
		// paste-code providers is the authoritative gate (it covers every caller, not
		// just the CLI); an explicit caller-supplied `onManualCodeInput` is still
		// honored for any provider as an escape hatch.
		const manualCodeInput = PASTE_CODE_LOGIN_PROVIDERS.has(provider)
			? () => ctrl.onPrompt({ message: "Paste the authorization code (or full redirect URL):" })
			: undefined;
		// Built-in registry first, then runtime-registered extension providers.
		const def = getProviderDefinition(provider) ?? getOAuthProvider(provider);
		if (!def?.login) {
			throw new AIError.ConfigurationError(`Unknown OAuth provider: ${provider}`);
		}
		const result = await def.login({
			onAuth: ctrl.onAuth,
			onProgress: ctrl.onProgress,
			onPrompt: ctrl.onPrompt,
			onManualCodeInput: ctrl.onManualCodeInput ?? manualCodeInput,
			signal: ctrl.signal,
			fetch: ctrl.fetch,
		});
		if (typeof result === "string") {
			// Some flows (e.g. ollama) return "" to signal that no key was entered.
			if (!result) {
				return undefined;
			}
			const newCredential: ApiKeyCredential = { type: "api_key", key: result, source: "login" };
			const stored = this.#store.upsertAuthCredentialRemote
				? await this.#store.upsertAuthCredentialRemote(provider, newCredential)
				: this.#store.upsertAuthCredentialForProvider(provider, newCredential);

View on GitHub (pinned to 9690622007)

Solutions

  1. Check the provider id spelling against the supported provider list (exact match)
  2. Register your custom provider with a login implementation via the runtime OAuth provider registry before calling login
  3. If the provider only supports API keys, use API-key storage instead of the OAuth login flow
  4. Ensure extension-provider registration code runs before any login attempt (import order/init timing)

Example fix

// before
await storage.loginOAuth("antrophic", ctrl); // typo
// after
await storage.loginOAuth("anthropic", ctrl);
Defensive patterns

Strategy: validation

Validate before calling

import { getOAuthProvider } from "@oh-my-pi/pi-ai";
if (!getOAuthProvider(provider)?.login && !BUILTIN_PROVIDERS.has(provider)) {
	throw new Error(`${provider} is not a login-capable OAuth provider`);
}

Try / catch

try {
	await storage.loginOAuth(provider, ctrl);
} catch (error) {
	if (error instanceof AIError.ConfigurationError && /Unknown OAuth provider/.test(error.message)) {
		showProviderListToUser();
	}
	throw error;
}

Prevention

When it happens

Trigger: Calling loginOAuth / the login control flow with a provider string that is not in the built-in registry and has no runtime-registered OAuth provider with a login() function — e.g. a typo, or a custom provider registered without a login implementation.

Common situations: Misspelled provider id (case-sensitive); attempting OAuth login for a provider that only supports API keys; custom OAuth provider registered via registerOAuthProvider without defining login; calling login before the extension provider registration ran.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/e76a88ddeaafdaa9. Report an issue: GitHub.