az account

Manage the signed-in account.

Commands

Name Description Type Status
az account get-access-token

Get an access token for the current signed-in context.

Core Preview

az account get-access-token

Preview

Get an access token for the current signed-in context.

Acquire an access token from the current signed-in context for a resource, a well-known resource type, or an explicit list of Microsoft Entra scopes. When no target is specified, a token for Azure Resource Manager (ARM) is returned. The token value is redacted by default and is not returned. Pass --plaintext to obtain the raw token value.

az account get-access-token [--plaintext]
                            [--resource]
                            [--resource-type {arm, aad-graph, ms-graph, batch, data-lake, oss-rdbms, media, key-vault, storage, synapse, managed-hsm, communication-email, attestation, app-configuration, analysis-services, operational-insights}]
                            [--scope]
                            [--tenant-id]

Examples

Get an access token for Azure Resource Manager (the default target)

az account get-access-token

Get an access token for a well-known resource type

az account get-access-token --resource-type ms-graph

Get an access token for a specific resource URL

az account get-access-token --resource https://vault.azure.net

Get an access token for an explicit list of scopes

az account get-access-token --scope https://graph.microsoft.com/.default

Print the raw access token as plain text

az account get-access-token --plaintext

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--plaintext

Emit the raw access token as plain text. By default the token is redacted in output.

--resource

Resource URL (v1.0) to acquire the token for. Mutually exclusive with --resource-type and --scope.

--resource-type

Well-known resource type shortcut (e.g. arm, ms-graph, key-vault). Mutually exclusive with --resource and --scope.

Property Value
Accepted values: arm, aad-graph, ms-graph, batch, data-lake, oss-rdbms, media, key-vault, storage, synapse, managed-hsm, communication-email, attestation, app-configuration, analysis-services, operational-insights
--scope

One or more Microsoft Entra v2.0 scopes. Mutually exclusive with --resource and --resource-type.

--tenant-id -t -tenant

Tenant ID to acquire the token for. Defaults to the current profile's tenant.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.