https://github.com/opentok/opentok-jwt
Node module to generate a JWT token given an apiKey and secret.
https://github.com/opentok/opentok-jwt
jwt opentok opentok-labs
Last synced: 18 days ago
JSON representation
Node module to generate a JWT token given an apiKey and secret.
- Host: GitHub
- URL: https://github.com/opentok/opentok-jwt
- Owner: opentok
- License: mit
- Created: 2018-10-05T10:07:31.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-07-09T03:36:55.000Z (almost 2 years ago)
- Last Synced: 2024-10-06T23:45:35.086Z (7 months ago)
- Topics: jwt, opentok, opentok-labs
- Language: JavaScript
- Homepage:
- Size: 1.27 MB
- Stars: 1
- Watchers: 10
- Forks: 4
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# opentok-jwt
Node module to generate a JWT token given an apiKey and secret.
Useful for automated tests against the Opentok API server or other scenarios when you might need to generate these tokens.## Install
```JS
npm install --save opentok-jwt
```## Usage
```JS
const { accountToken, generateToken, projectToken, verify } = require('opentok-jwt');const apiKey = ;
const apiSecret = ;const projectJWT = projectToken(apiKey, apiSecret);
const accountJWT = accountToken(apiKey, apiSecret);
// or
const projectJWT = generateToken(apiKey, secret, 'project');
const accountJWT = generateToken(apiKey, apiSecret, 'account');// With custom expiry (Default 30 days)
const expires = Math.floor(new Date() / 1000) + (24 * 60 * 60); // Now + 1 day
const accountJWT = accountToken(apiKey, apiSecret, expires);
const projectJWT = projectToken(apiKey, apiSecret, expires);
// or
const accountJWT = generateToken(apiKey, apiSecret, 'account', expires);
const projectJWT = generateToken(apiKey, apiSecret, 'project', expires);// Verify
const decoded = await verify(token, secret);
```## Development and Contributing
Interested in contributing? We :heart: pull requests! See the
[Contribution](CONTRIBUTING.md) guidelines.## Getting Help
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository
- See for support options
- Tweet at us! We're [@VonageDev](https://twitter.com/VonageDev) on Twitter
- Or [join the Vonage Developer Community Slack](https://developer.nexmo.com/community/slack)