Socket
Socket
Sign inDemoInstall

salesforce-jwt-bearer-token-flow

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

salesforce-jwt-bearer-token-flow

SalesForce OAuth 2.0 JWT Bearer Token Flow Implementation


Version published
Weekly downloads
14K
decreased by-6.69%
Maintainers
1
Weekly downloads
 
Created
Source

Salesforce OAuth 2.0 JWT Bearer Token Flow Implementation

Salesforce OAuth 2.0 JWT Bearer Token Flow

Installation

$ npm install salesforce-jwt-bearer-token-flow --save

Salesforce Configuration

Step 1 : The certificate

Create the private key and the certificate in osx terminal:

$ openssl req  -nodes -new -x509  -keyout private.pem -out server.cert

Step 2 : The connected App

Create a connected app in Salesforce:

  1. Select Enable OAuth Settings
  2. Select Use digital signatures
  3. Upload the generated certificate

Usage

Input

const   fs = require('fs')
    ,   privateKey = fs.readFileSync('private.pem').toString('utf8')
    ,   jwt = require("salesforce-jwt-bearer-token-flow")
;

var token = jwt.getToken({
        iss: "<YOUR_CONNECTED_APP_CLIENT_ID>",
        sub: "<YOUR_SALESFORCE_USERNAME>",
        aud: "<YOUR_AUDIENCE>",
        privateKey: privateKey
    },
    function(err, token){
        console.log(token);
    }
);

The audience (aud) must be:

Output

{
    access_token: 'xxxxxxxxxx!ARYAQNzk4LCbHsX[...]',
    scope: 'id full',
    instance_url: 'https://eu6.salesforce.com',
    id: 'https://login.salesforce.com/id/xxxxxxxxxxEAI/yyyyyyyyyy',
    token_type: 'Bearer'
}

License

MIT

Keywords

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc