Is your feature request related to a problem? Please describe.
We have received several feature requests that the user would like to provide their own access token, without interacting with AAD.
Azure PowerShell cmdlet Connect-AzAccount supports -AccessToken.
Describe the solution you'd like
az login should support either
Each az command should support a global argument --access-token which can be used together with --subscription to invoke ARM request:
az group list --access-token <access_token> --subscription <subscription_id>
I previously made a prototype: [Demo] Allow specifying a custom access token jiasli/azure-cli#12
Consume an environment variable AZURE_CLI_ACCESS_TOKEN so that all commands can use the same access token:
export AZURE_CLI_ACCESS_TOKEN=<access_token>
az group list
Also, since environment variables are preserved in memory, is it much safer than saving the access token to hard disk. Also see Enable authentication via environment variables #10241
Is your feature request related to a problem? Please describe.
We have received several feature requests that the user would like to provide their own access token, without interacting with AAD.
Azure PowerShell cmdlet
Connect-AzAccountsupports-AccessToken.Describe the solution you'd like
az loginshould support either--access-tokenargument which accepts an access token with Subscriptions - List permission:--access-token(may not have Subscriptions - List permission) and--subscriptionwhich explicitly specifies the default subscription (also see [Enhancement Proposal] Support--subscriptioninaz login#14933):Each
azcommand should support a global argument--access-tokenwhich can be used together with--subscriptionto invoke ARM request:I previously made a prototype: [Demo] Allow specifying a custom access token jiasli/azure-cli#12
Consume an environment variable
AZURE_CLI_ACCESS_TOKENso that all commands can use the same access token:Also, since environment variables are preserved in memory, is it much safer than saving the access token to hard disk. Also see Enable authentication via environment variables #10241