Integration of Salesforce using OAuth 2.0 client credentials flow configure-salesforce-with-ouath-2.0-client-credential
You can use OAuth 2.0 client credentials to integrate AEM Forms with the Salesforce application. OAuth 2.0 client credentials are a standard and secure method for direct communication without user involvement.
AEM Forms exchanges the client credentials (consumer key and consumer secret), defined in the Salesforce connected application, to obtain an access token.
There are multiple benefits of using OAuth 2.0 client credentials for authentication over Authorization Code Flow authentication:
- OAuth 2.0 client credentials authentication allows more than five connections per user.
- AEM data source configuration continues working on deactivation, access changes, password update for an AEM user.
Prerequisites prerequisites
Before setting communication between a Salesforce application and an AEM environment:
-
Create a Salesforce connected app with OAuth 2.0 client credential flow and an API-only user for your organization and obtain the consumer key and consumer secret for the app.
-
Ensure that your Swagger file is appropriately configured to match your organization’s APIs. Alternatively, you can opt to create a Swagger file from the scratch, tailored for utilization in your AEM environment.
+++
Steps to configure Salesforce with Client Credentials flow steps-to-create-aem-datasource-configuration
-
Log in to your Author instance.
-
Go to Tools > Cloud Services > Data Sources.
-
Select the configuration folder.
-
Click Create and the Create Data Source Configuration appears.
-
Specify the Title and select the Service Type as RESTful Service.
-
Click Next.
-
Select the Swagger Source as File.
note note NOTE As soon as the swagger file is selected, the Scheme, the Host name and the Base path are populated automatically. -
Upload the created swagger file from your local machine by clicking Browse.
-
Select the Authentication Type as OAuth 2.0 and the Authentication Settings panel appears.
-
Select the Grant Type as Client Credentials.
-
Specify the Client Id and Client Secret obtained from the Salesforce connected app.
-
Specify the Access Token URL in format
https://[MyDomainName].my.salesforce.com/services/oauth2/token
.note note NOTE Each organization has its own specific domain name. -
Click Test Connection.
-
If the connection succeeds, click the Create button.
Now, you can create the Form Data Model to integrate the configured datasource with your Adaptive Forms.