azure-cli: az login: request() got an unexpected keyword argument 'enable_cae'
Describe the bug
when running “az login” after authentication in the browser (safari or edge) a stack trace is shown:
Related command
az login
Errors
The command failed with an unexpected error. Here is the traceback: request() got an unexpected keyword argument 'enable_cae' Traceback (most recent call last): File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute raise ex File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job result = cmd_copy(params) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__ return self.handler(*args, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler return op(**command_args) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/command_modules/profile/custom.py", line 139, in login subscriptions = profile.login( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/_profile.py", line 176, in login subscriptions = subscription_finder.find_using_common_tenant(username, credential) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/_profile.py", line 759, in find_using_common_tenant subscriptions = self.find_using_specific_tenant(tenant_id, specific_tenant_credential) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/_profile.py", line 809, in find_using_specific_tenant for s in subscriptions: File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/paging.py", line 123, in __next__ return next(self._page_iterator) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/paging.py", line 75, in __next__ self._response = self._get_next(self.continuation_token) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py", line 519, in get_next pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/_base.py", line 227, in run return first_node.send(pipeline_request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/_base.py", line 89, in send response = self.next.send(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/_base.py", line 89, in send response = self.next.send(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/_base.py", line 89, in send response = self.next.send(request) [Previous line repeated 2 more times] File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/mgmt/core/policies/_base.py", line 46, in send response = self.next.send(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/policies/_redirect.py", line 184, in send response = self.next.send(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/policies/_retry.py", line 473, in send response = self.next.send(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/policies/_authentication.py", line 120, in send self.on_request(request) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/core/pipeline/policies/_authentication.py", line 96, in on_request self._token = self._credential.get_token(*self._scopes, enable_cae=self._enable_cae) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/azure/cli/core/auth/msal_authentication.py", line 69, in get_token result = self.acquire_token_silent_with_error(list(scopes), self._account, claims_challenge=claims, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/application.py", line 1279, in acquire_token_silent_with_error return _clean_up(self._acquire_token_silent_with_error( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/application.py", line 1301, in _acquire_token_silent_with_error result = self._acquire_token_silent_from_cache_and_possibly_refresh_it( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/application.py", line 1415, in _acquire_token_silent_from_cache_and_possibly_refresh_it result = self._acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/application.py", line 1471, in _acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family last_resp = at = self._acquire_token_silent_by_finding_specific_refresh_token( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/application.py", line 1521, in _acquire_token_silent_by_finding_specific_refresh_token response = client.obtain_token_by_refresh_token( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/oauth2cli/oauth2.py", line 830, in obtain_token_by_refresh_token resp = super(Client, self).obtain_token_by_refresh_token( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/oauth2cli/oauth2.py", line 262, in obtain_token_by_refresh_token return self._obtain_token("refresh_token", data=data, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/oauth2cli/oidc.py", line 116, in _obtain_token ret = super(Client, self)._obtain_token(grant_type, *args, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/oauth2cli/oauth2.py", line 771, in _obtain_token resp = super(Client, self)._obtain_token( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/oauth2cli/oauth2.py", line 234, in _obtain_token resp = (post or self._http_client.post)( File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/individual_cache.py", line 269, in wrapper value = function(*args, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/msal/individual_cache.py", line 269, in wrapper value = function(*args, **kwargs) File "/Users/bill.gates/Library/Python/3.9/lib/python/site-packages/requests/sessions.py", line 637, in post return self.request("POST", url, data=data, json=json, **kwargs) TypeError: request() got an unexpected keyword argument 'enable_cae'
Issue script & Debug output
confidential
Expected behavior
login should work like on my linux machine
Environment Summary
macOS 12.6.8 zsh 5.8.1 Python 3.9.6
azure-cli 2.51.0
core 2.51.0 telemetry 1.1.0
Extensions: front-door 1.0.17
Dependencies: msal 1.24.0b1 azure-mgmt-resource 23.1.0b2
Python location ‘/Library/Developer/CommandLineTools/usr/bin/python3’ Extensions directory ‘/Users/silicium/.azure/cliextensions’
Python (Darwin) 3.9.6 (default, Oct 18 2022, 12:41:40) [Clang 14.0.0 (clang-1400.0.29.202)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 23 (6 by maintainers)
@pvaneck is absolutely correct. Make sure you run
pip
from Azure CLI’s environment or use Azure CLI’s Python interpreter to runpip
. You may check the location of Azure CLI’s Python interpreter withaz --version
:Then run
@stanosaka, how did you install Azure CLI? You are using Python 3.11 which Azure CLI doesn’t support yet (https://github.com/Azure/azure-cli/pull/26923). The Python executable in Azure CLI’s DEB package is
/opt/az/bin/python3
.Root cause
This issue is causes by a change in
azure-core==1.29.0
which passesenable_cae
toget_token
protocol (https://github.com/Azure/azure-sdk-for-python/pull/31012). This unexpected argument breaks Azure CLI and MSAL.Solution
This issue has been fixed in
azure-core==1.29.1
which doesn’t passenable_cae
toget_token
protocol unlessenable_cae
is explicitly set toTrue
(https://github.com/Azure/azure-sdk-for-python/pull/31546).Please upgrade
azure-core
in Azure CLI’s environment to the latest version with*
pip
should be the one from Azure CLI’s environment.Additional Information
Installing Azure CLI with
pip
is not officially supported. If possible, we highly recommend following https://learn.microsoft.com/en-us/cli/azure/install-azure-cli to install official Azure CLI packages delivered by Microsoft.Here works for me, I just need to update the azure-core in pip to 1.29.1, in my case the the pip inside the azure-cli instalation. For example the
az --version
inform the location of the python that azure-cli are using:Python location '/home/gmoretti/.asdf/installs/azure-cli/2.51.0/bin/venv/bin/python3'
So I run
/home/gmoretti/.asdf/installs/azure-cli/2.51.0/bin/venv/bin/pip install azure-core==1.29.1
After that my login works!
A patch release of
azure-core
has been released (1.29.1
) which should resolve this issue for those newly installingazure-cli
from PyPI. However,enable_cae
still needs to be handled on the azure cli side as well for when it’s inevitably used by azure mgmt SDKs.Yes! pip install azure-core==1.28.0 fixed it for me!