top of page

How to Integrate any API with Salesforce Using Connected Apps

felipeelijah

This article will show how to integrate your external application with Salesforce through API and the OAuth 2.0 protocol, allowing you to access the data from Salesforce and edit, create, and delete records through Salesforce API.


Create a Connected App and retrieve both the credentials from the App to generate the Access Token


To consume the data from Salesforce through API and using OAuth 2.0, you'll need to create a Connected App, and to do this, on Salesforce Settings go to Setup > App Manager > New Connected App.


Salesforce Using Connected Apps - App Manager

After that, you must select "Create a Connected App" and while you're creating your Connected App, select the checkbox "Enable OAuth Settings", fill in the Callback URL, and choose one of the Options in the picklist "Selected OAuth Scopes", to grant access to Salesforce resources.


Salesforce Using Connected Apps - App Manager 2

Once the Connected App is generated by Salesforce, you need to go and click on "Manage Consumer Details" to retrieve the Client ID and Client Secret.


Salesforce Using Connected Apps

Lastly, click on Manage>Edit Policies and change the option of the field "IP Relaxation" from "Enforce IP restrictions" to "Relax IP restrictions" to avoid issues with the IP of the current use while generating the Access Token.


Generate Access Token


To access Salesforce from your Connected app through API, you'll need to generate an Access Token and to do this, you need to use one of the following endpoints for your POST Request:


Now, with your password, salesforce username, and user token in hand as well as the Client ID and Client Secret from your Connected App, use the following body for your request:

{  
	"grant_type": "password",  
	"client_id": "Connected_App_Client_ID",  
	"client_secret": "Connected_App_Client_Secret",  
	"username": "username@Salesforce.com",  
	"password": "Password_With_Security_Token"  
}

On Postman:

Salesforce Using Connected Apps -  Postmon

After that, Salesforce will return you the Access Token that you'll need to send all the requests from your App through API, as in the following image:


Salesforce Using Connected Apps - Access Token

Conclusion


Creating a Salesforce Connected App to build an integration with Salesforce using OAuth 2.0 protocol is one of the safest and easiest ways to integrate with Salesforce and by following the Steps of this article you'll be able to set up your integration to generate the Access Token required to do all the request you'll need to Salesforce.


For any questions please reach us at contact@brfconsulting.com


About the author: Felipe Elijah is a Salesforce Engineer at BRF Consulting, a Salesforce ISV partner specialized on Application Development and Data Engineering.

Comments


bottom of page