连接到第三方 API(基本身份验证)

Connecting to third party API (basic auth)

首先,我是 Salesforce 平台的新手。如果这是非常直接和明显的,那么提前道歉。

所以我们正在将我们的旧应用程序(基于 .net 平台)迁移到 Salesforce Community Cloud。应用程序中的一个组件连接到第三方 API 服务。第三方 API 端点使用基本身份验证。我们使用服务帐户凭据生成基本身份验证 header.

我们想使用社区生成器将此组件插入到页面中。因此,每当用户访问该页面时,该组件将从登录用户那里获取属性,点击第三方 API,获取所需信息并显示在页面上。

这在 Salesforce 中可行吗?如果是,实现此目标的最佳首选方法是什么?

基于代码的方法 - 如果您的 API 是基于 HTTP 的,则很容易通过 Apex callouts. The service account credentials should live in an instance of a Named Credential 在 Salesforce 中实施,它与标注一起工作。 Named Credential 会自动为你生成一个 Basic Auth header;命名凭据配置屏幕中的此选项被无用地称为 "Password Authentication"。

声明式方法:看看 External Services:

With External Services, you use SF tools to import Swagger or Interagent-based API definitions right into Salesforce using a schema. Once you import the definitions, you can create a flow based on the Apex classes generated from your External Services registration.