commonjs-oauth-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

oauth-client

Helper for exchanging authentication credentials

Config

Name Description
OAuthUrl OAuth Url for exchanging credentils

For logger configuration properties see the logger documentation

For resilient executor configuration properties see the resilient executor documentation

Usage

/** init oauthclient instance (should use 1 instance per app) */
import { OAuthClient } from 'commonjs-oauth-client';

const loggerConfig = : { logLevel: 'cli', logStyle: 'debug', appName: 'nodejs-commons', moduleName: 'ResilientExecutor' }, // logger configuration

const oauthClient = new OAuthClient('https://auth.dummy.test.url/oauth2/token', loggerconfig);

await oauthClient.exchangeCredentialsForToken({
        username: 'test',
        password: 'test',
      });


/** with resilient executor */

/** init oauthclient instance (should use 1 instance per app) */
import { OAuthClient } from 'commonjs-oauth-client';
import { ResilientExecutor } from 'http-resilient-executor';

const resilientConfig = {
  logger: { logLevel: 'cli', logStyle: 'debug', appName: 'nodejs-commons', moduleName: 'ResilientExecutor' }, // logger configuration
  httpResilienceCBHalfOpenAfterMS: 10 * 1000,
  httpResilienceCBConsecutiveThreshold: 5,
  httpResilienceRetryCount: 3,
};

const resilientExec = new ResilientExecutor(resilientConfig);

const oauthClient = new OAuthClient('https://auth.dummy.test.url/oauth2/token', loggerconfig, resilientExec);

await oauthClient.exchangeCredentialsForToken({
        username: 'test',
        password: 'test',
      });

Readme

Keywords

Package Sidebar

Install

npm i commonjs-oauth-client

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

52.5 kB

Total Files

12

Last publish

Collaborators

  • anokhi0895