Share via


AzureCliCredential class

This credential will use the currently logged-in user login information via the Azure CLI ('az') commandline tool. To do so, it will read the user access token and expire time with Azure CLI command "az account get-access-token".

Constructors

AzureCliCredential(AzureCliCredentialOptions)

Creates an instance of the AzureCliCredential.

To use this credential, ensure that you have already logged in via the 'az' tool using the command "az login" from the commandline.

Methods

getToken(string | string[], GetTokenOptions)

Authenticates with Microsoft Entra ID and returns an access token if successful. If authentication fails, a CredentialUnavailableError will be thrown with the details of the failure.

Constructor Details

AzureCliCredential(AzureCliCredentialOptions)

Creates an instance of the AzureCliCredential.

To use this credential, ensure that you have already logged in via the 'az' tool using the command "az login" from the commandline.

new AzureCliCredential(options?: AzureCliCredentialOptions)

Parameters

options
AzureCliCredentialOptions

Options, to optionally allow multi-tenant requests.

Method Details

getToken(string | string[], GetTokenOptions)

Authenticates with Microsoft Entra ID and returns an access token if successful. If authentication fails, a CredentialUnavailableError will be thrown with the details of the failure.

function getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>

Parameters

scopes

string | string[]

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

options
GetTokenOptions

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

Returns

Promise<AccessToken>