April 20, 2020
Estimated Post Reading Time ~

AEM Integration with Salesforce

Adobe AEM provides its extendable capabilities to integrate with other products. The below demonstration describes how to connect Adobe AEM with Salesforce which is the market’s leading cloud-based CRM System. AEM provides OOTB components for integration purposes. It helps the organization to target the customers through web channels as per their status in CRM.

Steps to Connect to Salesforce:
AEM uses the OAuth mechanism to connect to Salesforce. So, first, we need to create a connected app inside salesforce to get customer secret and access token.

Go to login.salesforce.com. Click on Setup on the top right corner. Search for Apps and create a custom app. Fill in the required details as shown in the below images. Callback Url here accepts only https URLs, so our AEM must be SSL configured. Check here how to configure SSL in AEM. Callback url is the url of cloud service that we will create in AEM.


Create a new custom app

Fill in the required details.



Select an image for your app.


Choose the required tabs for your custom app.


Choose the user profile for which the custom app will be visible in the Force.com AppExchange menu. You can make a custom app as the default custom app of the profile. If a custom app is set as the default for a profile, then you cannot make it invisible for that profile.


Create a new connected app.
Search for apps in setup. Goto apps, scroll down to Connected apps section, and create a new connected app.

  • Fill all the required fields.
  • Enable OAuth settings
  • Enter the callback url. Callback url should be HTTPS. Check here how to enable HTTPS in AEM.
  • Select the OAuth scopes. The connection may not be established if scopes are not selected appropriately. A connection was not successful when I have selected only "Full Access". So I selected all the OAuth scopes.
  • Click on the Manage button and Enable IP relaxation.
  • Take note of consumer key and consumer secret. We need to enter these values in the Salesforce cloud configuration in AEM.


That's all your salesforce app is created. Now let's establish a connection from AEM to Salesforce.

Create a salesforce cloud configuration:
Log in to your AEM instance and navigate to http://localhost:4502/miscadmin#/etc/cloudservices/salesforce. Click on new and create a new cloud configuration.

Double click on the newly created cloud service configuration to edit. Login url will be auto-populated on the dialog. Enter customer key and customer secret and click on connect to salesforce. If the connection is successful, then success alert will be displayed as shown below.


Troubleshooting:
  • Callback url should be HTTPS. Check here how to enable HTTPS in AEM.
  • The callback URL should be the fully qualified path of your configuration page with extension.
  • If we get this error response{"error":"invalid_grant","error_description":"authentication failure"} then check the authorization_url value. This value is hardcoded in the dialog in the connector. So when we try to connect to ****.salesforce.com it tries to establish a connection to login.salesforce.com.
  • Adobe salesforce connector uses TLS 1.0 to connect to salesforce. Salesforce disabling TLS 1.0. Check Adobe's TLS 1.0 support ending - FAQ. Salesforce is requiring an upgrade to TLS 1.1 or higher by July 22, 2017. After clicking connect to salesforce, check browser console logs to see if any errors.
  • Salesforce connector may not be able to connect successfully if AEM is behind a proxy. Enable proxy in Open Day Commons HTTP Client 3.1 and Apache HTTP Components Proxy Configuration. If that doesn't work then you may need to extend the connector and modify SalesforceClient.java.
  • Make sure to give the appropriate OAuth scope for the connected app. In salesforce we need to remove Full Access (Full) OAuth Scopes, if we use this then refresh token will not be effective. Check here for more info.
  • Sometimes we may not be able to refresh the Salesforce access_token using the rest api. Check here to resolve it.
  • Salesforce takes 5-10 min to enable the app after creation, so connect AEM with Salesforce after that.
By now you will be able to establish a connection to Salesforce.
URL:
https://helpx.adobe.com/experience-manager/6-4/sites/administering/using/salesforce.html


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.