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:
- Select Enable OAuth Settings
- Select Use digital signatures
- Upload the generated certificate
Usage
Input
const fs = privateKey = fs jwt = ; var token = jwt;
The audience (aud) must be:
- https://login.salesforce.com,
- https://test.salesforce.com
- https://acme.force.com/customers (where acme.force.com/customers is your community URL)
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