Skip to main content

Development

Integrating AEM with Salesforce – Part 2

Christine introduced how to integrate AEM with Salesforce by using the OOTB Salesforce plugin in Part1. We know how to create a connected app in Salesforce, connect it and use it do simple query operations via the OOTB plugin. But how can we do customized CRUD in our real project? In this part, I will discuss how to connect with Salesforce in code and query data from Salesforce using REST API.

1. Get Consumer Key and Consumer Secret from your connected app.

Integrating AEM with Salesforce

2. Setup OAuth2 in your code. Salesforce uses the OAuth protocol to allow users of applications to securely access data without having to reveal their username and password credentials. Username, password, authorizationURL, consumer key and consumer secret are necessary.

Integrating AEM with Salesforce

Notes: If you get a 400 error in your http request when getting your token, append your security token to your password. For example, if your password is mypassword, and your security token is 123, then the password in your code should be mypassword123. The security token is associated with your Salesforce account. Follow the steps from the screenshot to get your security token.

Integrating AEM with Salesforce

3. Access data from Salesforce. There are 2 knowledge articles in my Salesforce,

Integrating AEM with Salesforce

I want to access and show them in my project. Use SOQL in your code to access the data from Salesforce.

Integrating AEM with Salesforce

Integrating AEM with Salesforce

Set the http request header, add your token from Step2, then the response containing the articles will return successfully.

Integrating AEM with Salesforce

Reference:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_what_is_rest_api.htm

https://blogs.perficient.com/delivery/blog/2017/08/07/integration-aem-with-salesforce-part1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories
Follow Us