@wristband/node-m2m-auth
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published
Github

Enterprise-ready auth that is secure by default, truly multi-tenant, and ungated for small businesses.

WebsiteDocumentation




Wristband Machine-to-Machine Authentication SDK for NodeJS

npm package version number Actions Status License

Overview

This SDK can be used by Wristband machine-to-machine clients to retrieve an access token. The access token is cached in memory for subsequent calls. When the access token expires, the SDK will automatically get a new access token. The cached access token is tied to an instance of a WristbandM2MClient. Therefore, it's optimal to create a single instance of the WristbandM2MClient so that the access token cache will be utilized globally.

Install from NPM

npm install @wristband/node-m2m-auth

Usage

import { WristbandM2MClient } from '@wristband/node-m2m-auth'

const APPLICATION_DOMAIN=process.env.APPLICATION_DOMAIN;  // env variables
const CLIENT_ID=process.env.CLIENT_ID;
const CLIENT_SECRET=process.env.CLIENT_SECRET;

const wristbandM2MClient = new WristbandM2MClient( {
  appDomain: APPLICATION_DOMAIN, clientId: CLIENT_ID, clientSecret: CLIENT_SECRET
});

const accessToken = await wristbandM2MClient.getToken();

Configuration

APPLICATION_DOMAIN - This is the vanity domain for the Wristband application associated to the machine-to-machine client.

CLIENT_ID - This is the Wristband machine-to-machine client ID.

CLIENT_SECRET - This is the Wristband machine-to-machine client secret.

SDK Methods

getToken() - This method retrieves an access token for the machine-to-machine client. The access token is cached in memory for subsequent calls. When the access token expires, this method will automatically get a new access token when it's called.

clearToken() - This method clears the access token in the cache.

Package Sidebar

Install

npm i @wristband/node-m2m-auth

Weekly Downloads

5

Version

1.0.5

License

MIT

Unpacked Size

69.1 kB

Total Files

99

Last publish

Collaborators

  • bryhsiao
  • david.chu
  • jimverducci