onesignal-jwt-generator
v0.3.3
Published
Generate JWT tokens for your OneSignal integration.
Downloads
1
Readme
JWT Generator for OneSignal
A simple JWT token generator for OneSignal. This module allows you to set your app's secret and generate JWT tokens easily.
Installation
Install the package using npm:
npm install onesignal-jwt-generator
Usage
First, import the JwtGenerator
class:
import JwtGenerator from 'onesignal-jwt-generator';
Next, create an instance and set your app's secret:
const jwtGenerator = new OneSignalJwtGenerator();
jwtGenerator.setSecret('your-apps-256bit-device-api-shared-secret');
You can now generate JWT tokens by calling the createJwtToken
method with your app ID and identity object:
const identity = {
external_id: 'rodrigo',
onesignal_id: 'ea62cd50-e06f-11ed-b5ea-0242ac120002'
};
const jwtToken = jwtGenerator.createJwtToken('your-app-id', identity);
console.log(jwtToken);