How to Authenticate Salesforce Using JWT from MuleSoft?

on

|

views

and

comments

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 Singhhttps://www.pantherschools.com/
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
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

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

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential