This package contains an OAuth2 client. It aims to be a fully-featured OAuth2 utility library, for Node.js, Browsers and written in Typescript. This O

badgateway/oauth2-client

submited by
Style Pass
2022-06-21 23:00:08

This package contains an OAuth2 client. It aims to be a fully-featured OAuth2 utility library, for Node.js, Browsers and written in Typescript.

This OAuth2 client is only 3KB gzipped, it has 0 dependencies and relies on modern APIs like fetch() and Web Crypto which are built in Node 18 (but it works with Polyfills on Node 14 and 16).

This library provides support for these steps, but there's no requirement to use its functionality as the system is mostly stateless.

When using an OAuth2-protected API, typically you will need to obtain an Access token, and then add this token to each request using an Authorization: Bearer header.

To make this easier, this library has a 'fetch wrapper'. This is effectively just like a regular fetch function, except it automatically adds the header and will automatically refresh tokens when needed.

After set up, you can just call fetch on the new object ot call your API, and the library will ensure there's always a Bearer header.

Leave a Comment