Skip to content

Az cli does not refresh msgraph token cache #25442

@cveld

Description

@cveld

Describe the bug

After having consented the service principal for the msgraph app permission "Group.Read.All", the token cache is still providing a token without this permission. This results in a 403.

Even after:

az logout
az login -u ... -p ...

The 403 still happens.

I need to execute az account clear to delete the token cache, or what works better, remove the file msal_token_cache.bin from disk. This does not require a new login, but enforces the cli to retrieve a fresh access token.

Command Name
az ad group show

Errors:

Insufficient privileges to complete the operation.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Login with a service principal without any permissions
  • Add Group.Read.All
  • az logout
  • az login
  • az ad group show --group mygroup

Yields a 403

Expected Behavior

The cli should flush the tokens whenever an az logout happens.

Environment Summary

Windows-10-10.0.22621-SP0
Python 3.10.5
Installer: MSI

azure-cli 2.40.0 *

Additional Context

Metadata

Metadata

Assignees

Labels

Accountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamGraph(doesn't work with label-triggered comments; use Graph.Microsoft instead) az adact-identity-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions