different-ai/openwork · error

`${t("providers.no_oauth_prefix")} ${resolved}. ${t("provide

Error message

`${t("providers.no_oauth_prefix")} ${resolved}. ${t("providers.use_api_key_suffix")}`

What it means

startProviderOAuth needs an OAuth method for the chosen provider. It resolves oauthIndex either from the explicit methodIndex argument or by finding the first method with type === "oauth". If neither yields an index (oauthIndex === -1), the provider only offers non-OAuth methods (e.g. API key entry), so the store throws the no_oauth_prefix/use_api_key_suffix message directing the user to the API-key flow.

Source

Thrown at apps/app/src/react-app/domains/connections/provider-auth/store.ts:1428

      }

      const resolved = providerId?.trim() ?? "";
      if (!resolved) {
        throw new Error(t("providers.provider_id_required"));
      }
      assertProviderAllowedByDesktopPolicy(resolved);

      const methods = authMethods[resolved];
      if (!methods || !methods.length) {
        throw new Error(`${t("providers.unknown_provider")}: ${resolved}`);
      }

      const oauthIndex =
        methodIndex !== undefined
          ? methodIndex
          : methods.find((method) => method.type === "oauth")?.methodIndex ?? -1;
      if (oauthIndex === -1) {
        throw new Error(
          `${t("providers.no_oauth_prefix")} ${resolved}. ${t("providers.use_api_key_suffix")}`,
        );
      }

      const selectedMethod = methods.find((method) => method.methodIndex === oauthIndex);
      if (!selectedMethod || selectedMethod.type !== "oauth") {
        throw new Error(`${t("providers.not_oauth_flow_prefix")} ${resolved}.`);
      }

      const auth = unwrap(
        await c.provider.oauth.authorize({ providerID: resolved, method: oauthIndex }),
      );
      return { methodIndex: oauthIndex, authorization: auth };
    } catch (error) {
      const message = describeProviderError(error, t("providers.connect_failed"));
      setStateField("providerAuthError", message);
      throw error instanceof Error ? error : new Error(message);
    }

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Use the API-key connection flow for this provider instead of OAuth.
  2. Pass a valid methodIndex that corresponds to a method with type === "oauth" if one exists under a different index.
  3. Check methods list (c.provider.auth()[providerId]) to see which auth types the server offers.
  4. Reconfigure the server provider to include an OAuth method if OAuth is desired.

Example fix

// before
await startProviderOAuth("openai"); // only api-key method on server
// after: use API key flow
await store.getState().saveProviderApiKey("openai", apiKey);
Defensive patterns

Strategy: validation

Validate before calling

const methods = authMethods[providerId] ?? [];
const hasOAuth = methods.some((m) => m.type === "oauth");
if (!hasOAuth) {
  // route to API-key flow instead
  openApiKeyDialog(providerId);
  return;
}

Type guard

function hasOAuthMethod(methods: ProviderAuthMethod[]): boolean {
  return methods.some((m) => m.type === "oauth");
}

Try / catch

try {
  await store.startProviderOAuth(providerId);
} catch (e) {
  if (e instanceof Error && /no oauth/i.test(e.message)) {
    openApiKeyDialog(providerId);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling startProviderOAuth for a provider whose auth methods contain no type === "oauth" entry (e.g. only 'api' type methods), without supplying an oauth-capable methodIndex.

Common situations: Providers like OpenAI/Bedrock/etc. configured with API-key-only auth on this server; user picked a provider in the OAuth section that the server exposes only as API-key; methodIndex passed points at a non-oauth method; server config changed the method types after the UI was built.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/4a0e382dc95048cd. Report an issue: GitHub.