Search code examples
salesforcesalesforce-communities

Connecting to third party API (basic auth)


First of all, I am very new to the Salesforce platform. 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. One of the components in the app connects to the third party API service. The third party API endpoint uses Basic Authentication. 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.

Is this doable in Salesforce? If yes, what is the best preferred way of achieving this?


Solution

  • Code-based approach - If your API is HTTP-based it's easy to implement in Salesforce via Apex callouts. 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. Once you import the definitions, you can create a flow based on the Apex classes generated from your External Services registration.