# @ist-group/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.

Latest version **6.0.3** (published 2023-02-22) · 0 weekly downloads

## Install

```sh
npm install @ist-group/client-credentials-access-token-provider
pnpm add @ist-group/client-credentials-access-token-provider
yarn add @ist-group/client-credentials-access-token-provider
bun add @ist-group/client-credentials-access-token-provider
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.3 |
| Published | 2023-02-22 |
| First published | 2019-05-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Henrik Cooke |
| Maintainers | tkwawaboo, rhine, gabts |

## Links

- npm: https://www.npmjs.com/package/@ist-group/client-credentials-access-token-provider
- npm.io page: https://npm.io/package/@ist-group/client-credentials-access-token-provider

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.2.1

## Recent versions

- 6.0.3 (latest) — 2023-02-22
- 6.0.2 — 2022-12-06
- 6.0.1 — 2021-11-12
- 6.0.0 — 2021-06-04
- 5.0.1 — 2021-06-04
- 5.0.0 — 2021-06-04
- 4.1.0 — 2021-06-04
- 4.0.0 — 2020-02-19
- 3.2.1 — 2019-10-09
- 3.2.0 — 2019-10-09
- 3.1.0 — 2019-10-09
- 3.0.2 — 2019-09-09
- 3.0.1 — 2019-09-09
- 3.0.0 — 2019-09-09
- 2.0.3 — 2019-08-23
- … 5 more at https://npm.io/package/@ist-group/client-credentials-access-token-provider/versions

## README

# 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

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

## Usage

```javascript
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.

---
_Source: https://npm.io/package/@ist-group/client-credentials-access-token-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
