简体   繁体   English

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

[英]Connecting to third party API (basic auth)

First of all, I am very new to the Salesforce platform. 首先,我是Salesforce平台的新手。 So apologies in advance if this is very straight forward and obvious. 如果这很简单明了,请提前道歉。

So we are migrating our old app (based on .net platform) to Salesforce Community Cloud. 因此,我们正在将旧的应用程序(基于.net平台)迁移到Salesforce社区云。 One of the components in the app connects to the third party API service. 应用程序中的组件之一连接到第三方API服务。 The third party API endpoint uses Basic Authentication. 第三方API端点使用基本身份验证。 We use service account credentials to generate basic authentication header. 我们使用服务帐户凭据来生成基本身份验证标头。

We want to insert this component in a page using community builder. 我们想使用社区构建器将此组件插入页面中。 So whenever users visit the page, the component will pick the properties from logged in user, hit the third party API, get the required information and show on the page. 因此,每当用户访问该页面时,该组件都会从已登录用户那里选择属性,点击第三方API,获取所需信息并显示在页面上。

Is this doable in Salesforce? 这在Salesforce中可行吗? If yes, what is the best preferred way of achieving this? 如果是,实现此目标的最佳首选方法是什么?

Code-based approach - If your API is HTTP-based it's easy to implement in Salesforce via Apex callouts . 基于代码的方法-如果您的API是基于HTTP的,则可以通过Apex标注在Salesforce中轻松实现。 The service account credentials should live in an instance of a Named Credential , it works together with a callout. 服务帐户凭据应位于命名凭据的实例中,它可以与标注一起使用。 Named Credential will automatically generate a Basic Auth header for you; 命名凭据将自动为您生成一个基本身份验证标头; this option in the Named Credential config screen is unhelpfully called "Password Authentication". 在“命名凭据”配置屏幕中,此选项无益地称为“密码身份验证”。

Declarative-ish approach: take a look at External Services : 声明式方法:看一下外部服务

With External Services, you use SF tools to import Swagger or Interagent-based API definitions right into Salesforce using a schema. 通过外部服务,您可以使用SF工具使用架构将Swagger或基于Interagent的API定义直接导入Salesforce。 Once you import the definitions, you can create a flow based on the Apex classes generated from your External Services registration. 导入定义后,您可以基于从外部服务注册生成的Apex类创建流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM