Skip to content

psylence303/sf-jwt-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SalesForce JWT generator

Generates a JWT using the provided config. Then it's your part to use this JWT to retrieve the actual token from SF OAuth.

Installation

yarn

Configuration

The configuration has the following properties (all of them except the offsetInMs are mandatory):

const config = {
    clientId: '<YOUR CLIENT ID HERE>',
    offsetInMs: '<HOW MANY MILLISECONDS THE TOKEN IS VALID (OPTIONAL, DEFAULT IS 1 DAY)',
    privateKey: '<YOUR PRIVATE KEY AS UTF-8 STRING>',
    url: '<SALESFORCE BASE URL>',
    username: '<YOUR SALESFORCE USERNAME>'
}

The url should be one of:

https://login.salesforce.com
https://test.salesforce.com

Usage

import {generateJwt} from 'sf-jwt-generator';

const jwt = generateJwt(config); // the config provided above

To import the config type definition in TypeScript:

import {ConnectionConfig} from 'sf-jwt-generator';

const config:ConnectionConfig = {
    // config here
}

About

Generate JWT for the SalesForce OAuth endpoint

Resources

Stars

Watchers

Forks

Packages

No packages published