{"record":{"id":"4a0e382dc95048cd","repo":"different-ai/openwork","slug":"t-providers-no-oauth-prefix-resolved","errorCode":null,"errorMessage":"`${t(\"providers.no_oauth_prefix\")} ${resolved}. ${t(\"providers.use_api_key_suffix\")}`","messagePattern":"`\\$\\{t\\(\"providers\\.no_oauth_prefix\"\\)\\} \\$\\{resolved\\}\\. \\$\\{t\\(\"providers\\.use_api_key_suffix\"\\)\\}`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":1428,"sourceCode":"      }\n\n      const resolved = providerId?.trim() ?? \"\";\n      if (!resolved) {\n        throw new Error(t(\"providers.provider_id_required\"));\n      }\n      assertProviderAllowedByDesktopPolicy(resolved);\n\n      const methods = authMethods[resolved];\n      if (!methods || !methods.length) {\n        throw new Error(`${t(\"providers.unknown_provider\")}: ${resolved}`);\n      }\n\n      const oauthIndex =\n        methodIndex !== undefined\n          ? methodIndex\n          : methods.find((method) => method.type === \"oauth\")?.methodIndex ?? -1;\n      if (oauthIndex === -1) {\n        throw new Error(\n          `${t(\"providers.no_oauth_prefix\")} ${resolved}. ${t(\"providers.use_api_key_suffix\")}`,\n        );\n      }\n\n      const selectedMethod = methods.find((method) => method.methodIndex === oauthIndex);\n      if (!selectedMethod || selectedMethod.type !== \"oauth\") {\n        throw new Error(`${t(\"providers.not_oauth_flow_prefix\")} ${resolved}.`);\n      }\n\n      const auth = unwrap(\n        await c.provider.oauth.authorize({ providerID: resolved, method: oauthIndex }),\n      );\n      return { methodIndex: oauthIndex, authorization: auth };\n    } catch (error) {\n      const message = describeProviderError(error, t(\"providers.connect_failed\"));\n      setStateField(\"providerAuthError\", message);\n      throw error instanceof Error ? error : new Error(message);\n    }","sourceCodeStart":1410,"sourceCodeEnd":1446,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1410-L1446","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the API-key connection flow for this provider instead of OAuth.","Pass a valid methodIndex that corresponds to a method with type === \"oauth\" if one exists under a different index.","Check methods list (c.provider.auth()[providerId]) to see which auth types the server offers.","Reconfigure the server provider to include an OAuth method if OAuth is desired."],"exampleFix":"// before\nawait startProviderOAuth(\"openai\"); // only api-key method on server\n// after: use API key flow\nawait store.getState().saveProviderApiKey(\"openai\", apiKey);","handlingStrategy":"validation","validationCode":"const methods = authMethods[providerId] ?? [];\nconst hasOAuth = methods.some((m) => m.type === \"oauth\");\nif (!hasOAuth) {\n  // route to API-key flow instead\n  openApiKeyDialog(providerId);\n  return;\n}","typeGuard":"function hasOAuthMethod(methods: ProviderAuthMethod[]): boolean {\n  return methods.some((m) => m.type === \"oauth\");\n}","tryCatchPattern":"try {\n  await store.startProviderOAuth(providerId);\n} catch (e) {\n  if (e instanceof Error && /no oauth/i.test(e.message)) {\n    openApiKeyDialog(providerId);\n  } else throw e;\n}","preventionTips":["Check method types from the server before offering the OAuth option in the UI.","Fall back to the API-key flow for providers without OAuth methods.","Do not assume all providers support OAuth; render auth options from the method list.","Keep the server provider config in sync with the flows the UI exposes."],"tags":["oauth","validation","provider-auth"],"backgroundTag":"oauth-not-supported-for-provider","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}