6.0.3 • Published 1 year ago

@ist-group/client-credentials-access-token-provider v6.0.3

Weekly downloads
8
License
-
Repository
-
Last release
1 year ago

Client Credentials - Access Token Provider

The purpose of this module is to provide a rebost and failure tolerant way to fetch access tokens with the client credentials OAuth2 flow WITHOUT SPAMMING the token server.

Install

yarn add @ist-group/client-credentials-access-token-provider

Usage

import { AccessTokenProvider } from "@ist-group/client-credentials-access-token-provider";

const tokenProvider = new AccessTokenProvider({
  tokenEndpoint: 'https://example.com/token',
  clientId: 'client-id',
  clientSecret: 'client-secret',
  scopes: ["scope1", "foo"], // Optional, limit the token to the following scopes
  disableAutomaticUpdate: true, // Optional, default: false
  onUpdateError: (err) => { // Optional, output is logged to std-out if not defined
    console.log("Error fetching token", err.message);
  }
});

tokenProvider.getToken().then(accessToken => { .... });

Remarks

The instances of the AccessTokenProvider is intended to be reused and shared across your application.

The options includes a scopes property that is recommended to use when fetching tokens that will be used aginst "untrusted" API:s.

6.0.3

1 year ago

6.0.2

1 year ago

6.0.1

2 years ago

5.0.1

3 years ago

5.0.0

3 years ago

6.0.0

3 years ago

4.1.0

3 years ago

4.0.0

4 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago