Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
jsforce with jwt
const jsforce = require('jsforce');
const jwt = require("salesforce-jwt-bearer-token-flow");
// create the connection to the org
let conn = new jsforce.Connection();
// load the private key for the token
let privateKey = require('fs').readFileSync('./server.key', 'utf8');
iss: process.env.CLIENT_ID,
sub: process.env.USERNAME,
aud: process.env.LOGIN_URL,
privateKey: privateKey
}, function(err, response) {
if (err) {
} else {
instanceUrl: response.instance_url,
accessToken: response.access_token
console.log('Successfully connected to Org');
module.exports = conn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment