At times, it’s required for you to share Salesforce object’s data with external systems for Integration. You can do it by using a Salesforce connected app and an Apex Class that exposes data.
Steps for Salesforce Integration
You need a Connected App for your custom API to be exposed to an external system. In the Connected App, you define different things the user can do once he is authenticated to Salesforce. To create a connected App follow these steps
- Go to Setup.
- Search for App Manager.
- Click on New Connected App.
- Give the Name and API Name for the app and click on Enable OAuth Settings.
- Here you can set what type of access will the user of this app have.
- Click on Save.
- When the connected App is created, you can see the below details that can be used for authentication.
- We will discuss on authentication in the next part.
Common OAuth Terms
For security reasons, we can’t give password of the Salesforce User to any external system. Hence instead of using the user’s Salesforce credentials, a connected app can use an access token to grant access to protected resources on behalf of the user.
For OAuth 1.0.A, the access token must be exchanged for a session ID.
For OAuth 2.0, the access token is a session ID and can be used directly.
Only used in OAuth 2.0 with the web server flow, the authorization code is a token that represents the access granted by the end user. The authorization code is used to obtain an access token and a refresh token. It expires after 15 minutes.
To successfully set up a Salesforce integration with an external system, you need to first set up a connection with a connected app. Then expose the Salesforce data afterward, as the API you expose needs to be authenticated first. We will discuss more in the next part.
To learn more about what Apex can do for your org, check out some of my related blogs below!