How to Authenticate Salesforce Using JWT from MuleSoft?

You are working as a Developer for a Big company and the ask is to migrate the Products from Salesforce

Dear #Trailblazers,

In this blog post, we are going to learn how to authenticate the Salesforce Org using JWT from MuleSoft Anypoint studio.

Prerequisites

  1. Salesforce Developer/Sandbox/Production org
  2. 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

  1. Access and manage your data (API)
  2. Access your basic information (id, profile, email, address, phone)
  3. Full access (full)
  4. Perform requests on your behalf at any time (refresh_token, offline_access)
  5. 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 ConnectorThe values to be mapped
Consumer KeyThe Consumer Key from the Connected Application.
Key StoreThe .jsk file ( The key file that you have exported in step2 )
PrincipalThe Salesforce ORG UserName
Store PasswordThe 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

Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

4 Comments

  1. […] 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? […]

Leave a Reply

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

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading