Skip to content

Request token via az account get-access-token for Graph using multiple scopes #30878

@christothes

Description

@christothes

Describe the bug

Azure.Identity invokes AzureCLI for token requests in its AzureCliCredential implementation. I am wondering if there is a way to invoke az account get-access-token to get a token for Azure Graph with multiple scopes. In the comment of this issue, I tried it a few different ways and it wasn't clear how it can be done.

Currently in Azure.Identity, we only allow a single scope and pass it to the --resource switch on the CLI. But if we wanted to allow multiple scopes, it is unclear how we would call the CLI to do this. Is it true that this is not possible, or is there a syntax that would work here?

Related command

az account get-access-token

Errors

Status: Response_Status.Status_IncorrectConfiguration, Error code: 3399614471, Tag: 508634083
Please explicitly log in with:
az login --scope https://graph.microsoft.com/.default User.Read

Issue script & Debug output

n/a

Expected behavior

CLI can fetch a token for multiple scopes.

Environment Summary

azure-cli 2.67.0 *

core 2.67.0 *
telemetry 1.1.0

Extensions:
azure-dev 0.0.1b1532057
azure-devops 1.0.1
serial-console 0.1.6
ssh 2.0.2

Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\chriss.azure\cliextensions'

Python (Windows) 3.12.7 (tags/v3.12.7:0b05ead, Oct 1 2024, 02:44:45) [MSC v.1941 32 bit (Intel)]

Additional context

No response

Metadata

Metadata

Assignees

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAccountaz login/accountAuto-AssignAuto assign by botAuto-ResolveAuto resolve by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamOKR CandidateThis label is used to track how many GitHub issues we have resolved for OKR purpose.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions