Dear #Trailblazers,
In this blog post, we are going to learn how to authenticate the Salesforce Org using JWT from MuleSoft Anypoint studio.
Prerequisites
- Salesforce Developer/Sandbox/Production org
- MuleSoft Anypoint Studio Installed
Use Case
You are working as a Developer for a Big company and the ask is to migrate the Products from Salesforce to Legacy System and From Legacy System to Salesforce. The business wants that you need to use MuleSoft as middle ware and JWT will be used to authenticate Salesforce.
Let’s Implement
Step1 – Generate a Self Signed Certificate
Login to Your Salesforce Org and navigate to Setup -> Security -> Certificate and Key Management and Click on Create Self-Signed Certificate button.
Provide the Label and click on Save and then Click on the Download Certificate button.
Note: – Save this file we will be needing this is further steps.
Step2 – Export the Key and Store into Your Local PC
Again navigate to Setup -> Security -> Certificate and Key Management and Click on Export to KeyStore button, provide a password and Click on Export.
Note: – Save this file we will be needing this is further steps.
Step3 – Create a New Connected Application
Setup -> App Manager -> and then Click on “New Connected App”
Provide the Name and the Contact Email. Check Enable OAuth Settings checkbox under API (Enable OAuth Settings) accordion.
Provide the below values for Callback URL
https://login.salesforce.com/services/oauth2/success
https://test.salesforce.com/services/oauth2/success
Check Use digital signatures checkbox and browse your self-signed certificate. Note: – Make sure that you are using the .crt file not .jks.
For Scopes Select below from available values
- Access and manage your data (API)
- Access your basic information (id, profile, email, address, phone)
- Full access (full)
- Perform requests on your behalf at any time (refresh_token, offline_access)
- Provide access to your data via the Web (web)
Click on Save and then Click on Manage button and then click on Edit Policies button.
Change the value to “Admin approved users are pre-authorized” for Permitted Users picklist value under OAuth Policies
and click on Save.
Now, Click on Manage Profile, Select The profile which you wanted to provide access for, and then click on save.
The Salesforce connected application work is done.
Step4 – Setup MuleSoft Application
Open MuleSoft Application and Create a New Project
Drag & Drop the Query Component for Salesforce Connector and Now, Go to Global Elements Tab and Click on Create Button
For Connections Select oAuth JWT and check below table for the values
MuleSoft Connector | The values to be mapped |
Consumer Key | The Consumer Key from the Connected Application. |
Key Store | The .jsk file ( The key file that you have exported in step2 ) |
Principal | The Salesforce ORG UserName |
Store Password | The password that you have used to export the key file |
Click on Test Connection
Hurray, Now you are done with the setup.
Thanks for reading 😉 Happy Learning
#Salesforce #MuleSoft
[…] your experience. We’ll assume you’re ok with this, but you can opt-out if you wish. Accept Read […]
[…] Web Component inside Visual… How to integrate Salesforce Platform Event using MuleSoft… How to Authenticate Salesforce Using JWT from MuleSoft? How to Master Apex Triggers? Apex Trigger Scenarios How to integrate your LinkedIn using […]
[…] Latest Posts How to implement sObject Tree in MuleSoft Composite… How To Implement Bidirectional Communication LWC With VF How to create Community User in Test Class? How to create a reusable Custom Lookup In… How to create a Rating Component in Lightning… How to Create and Update dependent picklist values… How to Configure Salesforce Composite Connector using Mule… How to use Lightning Web Component inside Visual… How to integrate Salesforce Platform Event using MuleSoft… How to Authenticate Salesforce Using JWT from MuleSoft? […]
[…] – Create Connected Application – Follow this link to create a connected application that supports JWT for […]