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:

Required 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.

Environment variables used for client credential authentication:

  • AZURE_CLIENT_SECRET: A client secret that was generated for the App Registration.
  • AZURE_CLIENT_CERTIFICATE_PATH: The path to a PEM certificate to use during the authentication, instead of the client secret.

Alternatively, users can provide environment variables for username and password authentication:

  • AZURE_USERNAME: Username to authenticate with.
  • AZURE_PASSWORD: Password to authenticate with.

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

  • any
  • any

Index

Constructors

Methods

Constructors

constructor

  • Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.

    Required 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.

    Environment variables used for client credential authentication:

    • AZURE_CLIENT_SECRET: A client secret that was generated for the App Registration.
    • AZURE_CLIENT_CERTIFICATE_PATH: The path to a PEM certificate to use during the authentication, instead of the client secret.

    Alternatively, users can provide environment variables for username and password authentication:

    • AZURE_USERNAME: Username to authenticate with.
    • AZURE_PASSWORD: Password to authenticate with.

    If the environment variables required to perform the authentication are missing, a CredentialUnavailableError will be thrown. If the authentication fails, or if there's an unknown error, an AuthenticationError will be thrown.

    Parameters

    Returns EnvironmentCredential

Methods

getToken

  • getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>
  • Authenticates with Azure Active Directory and returns an access token if successful.

    Parameters

    • scopes: string | string[]

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

    • Default value options: GetTokenOptions = {}

      Optional parameters. See {@link GetTokenOptions}.

    Returns Promise<AccessToken>

Generated using TypeDoc