nest-azure-ad-tokenator
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

NEST Azure AD Tokenator

Description

Nest Framework modules for requesting tokens from Azure AD based on scope (service requests vs user requests)

Scaffolded from nest-sftp (Nest framework module wrapper around ssh2-sftp-client).

Installation

$ npm install --save nest-azure-ad-tokenator

Register in AppModule

Register the AzureClientCredentialsModule in your App Module.

This version uses forRootAsync

import { AzureClientCredentialsModule } from 'nest-azure-ad-tokenator';

@Module({
  imports: [
    AzureClientCredentialsModule.forRootAsync({
      useFactory: (configService: ConfigService) => {
        return {
          applicationId: configService.get('APPLICATION_ID'),
          tenantId: configService.get('TENANT_ID'),
          clientSecret: configService.get('CLIENT_SECRET'),
        };
      },
      inject: [ConfigService],
      imports: [AppModule],
    }),
  ],
  controllers: [],
  providers: [ConfigService],
  exports: [ConfigService],
})
export class AppModule {}

Usage

export class AuthClient {
  constructor(
    private readonly azureClientCredentialsService: AzureClientCredentialsService,
  ) {}

  async getToken() {
    return await this.azureClientCredentialsService.getClientCredentialsToken();
  }
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

NEST Azure AD Tokenator is MIT licensed.

Package Sidebar

Install

npm i nest-azure-ad-tokenator

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

146 kB

Total Files

26

Last publish

Collaborators

  • sethdix