Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EnvironmentCredential

Package version

Enables authentication to Azure Active Directory using client secret details configured in the following environment variables:

  • AZURE_TENANT_ID: The Azure Active Directory tenant (directory) ID.
  • AZURE_CLIENT_ID: The client (application) ID of an App Registration in the tenant.
  • AZURE_CLIENT_SECRET: A client secret that was generated for the App Registration.

This credential ultimately uses a ClientSecretCredential to perform the authentication using these details. Please consult the documentation of that class for more details.

Hierarchy

  • EnvironmentCredential

Implements

  • TokenCredential
  • TokenCredential

Index

Constructors

Methods

Constructors

constructor

  • Creates an instance of the EnvironmentCredential class and reads client secret details from environment variables. If the expected environment variables are not found at this time, the getToken method will return null when invoked.

    Parameters

    • Optional options: TokenCredentialOptions

      Options for configuring the client which makes the authentication request.

    Returns EnvironmentCredential

Methods

getToken

  • getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>
  • Authenticates with Azure Active Directory and returns an access token if successful. If authentication cannot be performed at this time, this method may return null. If an error occurs during authentication, an AuthenticationError containing failure details will be thrown.

    Parameters

    • scopes: string | string[]

      The list of scopes for which the token will have access.

    • Optional options: GetTokenOptions

      The options used to configure any requests this TokenCredential implementation might make.

    Returns Promise<AccessToken | null>

Generated using TypeDoc