Implementing a JWT Server to Server OAuth between Salesforce and Heroku
Why Salesforce Stack Exchange recommends it
Salesforce Stack Exchange users link it as a step-by-step walkthrough when setting up JWT server-to-server authentication between Node.js or Heroku apps and Salesforce.
Recommended by 1 people across 1 different months, 2021 to 2022.
What it is
A Salesforce Developers session where Developer Advocate Mohith Shrivastava builds a Node.js app on Heroku that connects to Salesforce using the OAuth 2.0 JWT Bearer Flow. It walks through creating the private key and certificate, setting up a Connected App, deploying to Heroku and managing Connected App policies.
What people said
Recommends Mohith Shrivastava · 2021-07 · Salesforce Stack Exchange · on “oAuth flow for server-to-server calls”
Username and Password is definitely not recommended as the article says you are passing along the username and password and also there is a need to securely store these. In your case, you should use JWT Server-Server flow. In this flow, you also do not need a client secret. Note in JWT flow as well you should protect your JWT token. In the case of Salesforce, you will need to securely store your private key part of the certificate. One key differentiator with JWT is you can set the expiration time of your tokens. So if someone gets hold of it they won't have access to the system for longer. One consideration is to make sure that you do not store these tokens anywhere and go completely statel
Cites Kevin Stevens · 2021-07 · Salesforce Stack Exchange · on “Salesforce JWT User Hasn't Approved This Consumer (Again)”
Setting Admin approved users are pre-authorized means that you don't need to pre-authenticate, or need a prior refresh_token, so may be a preferred solution rather than going through a manual authenticate step. Don't forget to set a scope though! There's a SF walk-through video on YouTube: [this video]
Cites user43598 · 2021-12 · Salesforce Stack Exchange · on “error in node JS and SF integration via jsforce using JWT”
Premise: I need to integrate SF with NodeJs using JWT. I'm following Salesforce Developers Session [this video] for this purpose. As of now the entire setup of NodeJs is only in local. According to the video I have used the below code to achieve the integration. const fs = require('fs'); const compression = require("compression"); const express = require("express"); const helmet = require("helmet"); const jsforce = require("jsforce"); const { getToken } = require("sf-jwt-token"); const dotenv = require('dotenv'); const privateKey = fs.readFileSync('private.pem').toString('utf8') const result = dotenv.config(); if (result.error) { throw result.error } console.log('Hi'); console.log(result.parsed)
Cites Vitalii Dehnerys · 2022-09 · Salesforce Stack Exchange · on “Lightning Out : Uncaught ReferenceError: $A is not defined when user is not logged in”
I want to use my LWC 'in an External Site (Heroku). For it I use Lightning Out [LINK] . I have built a simple Aura Application (in my Sandbox ) according to documentation here : Lightning Out Dependencies [LINK] <aura:application access="Global" extends="ltng:outApp" > <aura:dependency resource="c:testLWC"/> </aura:application> I have implemented the OAuth using JWT [LINK] auth (based on this great video : Implementing a JWT Server to Server OAuth between Salesforce and Heroku [this video] ). The main method (which connects to Lightning Out ) in the Heroku : let renderLightningOutComponent = (token) => { $Lightning.use( "c:LightningOutDemo", function() { $Lightning.createComponent( "c:testLWC", {