azure-cli: `az login` fails due to MFA
Describe the bug
az login doesn’t work for me anymore with an MFA enabled user.
Failed to authenticate '{'additional_properties': {}, 'id': '/tenants/4253165e-ba77-4eaa-bd15-e7abb69a74ef', 'tenant_id': '4253165e-ba77-4eaa-bd15-e7abb69a74ef'}' due to error 'Get Token request returned http error: 400 and server response: {"error":"interaction_required","error_description":"AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '797f4846-ba00-4fd7-ba43-dac1f8f63013'.\r\nTrace ID: 384cee7c-cf4c-4dfe-8a11-a510c4e90c00\r\nCorrelation ID: 66394469-089e-42dc-aaf6-e5d6e77c7987\r\nTimestamp: 2018-08-03 12:27:46Z","error_codes":[50076],"timestamp":"2018-08-03 12:27:46Z","trace_id":"384cee7c-cf4c-4dfe-8a11-a510c4e90c00","correlation_id":"66394469-089e-42dc-aaf6-e5d6e77c7987","suberror":"basic_action"}'
To Reproduce
az login, also read -sp "Azure password: " AZ_PASS && echo && az login -u auobrien.david@outlook.com -p $AZ_PASS doesn’t work.
Expected behavior I receive an MFA prompt on my phone.
Environment summary
az --version
azure-cli (2.0.43)
Installed on WSL.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 30 (11 by maintainers)
This will happen if your account is associated with multiple Azure AD’s. It can exist as a member user in one Azure AD, and as a guest user in the other Azure AD. If the Azure AD that you are a guest user in requires MFA, this error will occur.
You can mitigate this ‘problem’ by adding the Azure AD tenant to the login:
az login --tenant [tenantid]
in your case:
az login --tenant 4253165e-ba77-4eaa-bd15-e7abb69a74ef
Closing. No actions I can take from CLI’s end to make it better, the issue is on the browser ui caches old auth configurations. If more users report the same error I will transfer to AAD/ESTS team who owns the whole browser based authentication flow.
@Bessonov, you may use
az login --use-device-codefor user login oraz login --service-principalfor service principal login. Please see Create an Azure service principal with Azure CLI for details.@sjentzsch, I have forwarded this to the AAD group, thanks for the feedback. What we have experienced are confusing, indeed.
I can reproduce this behavior by doing:
I ended up fixing this by re-opening the browser and re-login to the portal, which triggered the wizard for me to configure all needed for MFA authentication. After that, “az login” works again. Hope this help.
Try to use tenant ID when login in using CLI. Then you need to go through 2 steps of authentication.
I’m having this exact issue on azure-cli version 2.0.30. First noticed it a couple days ago.
Are you able to login in to portal? If yes, can you try
az loginagain?I think the best option is to:
But for sure something is not working correctly with “az login” looks like it does not get the appropriate cookies/tokens. I will try to debug it someday 😄
I think my issue was caused by a bug in az which was fixed. It works fine for me with the latest
I have the same problem. I am logged in to my companies Office 365 tenant but we have another tenant for Azure DevOps where I am a “guest” using my Office365 e-mail. My companies Office 365 has no MFA but the DevOps ADD has MFA. “az login” fails with “AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access”
"az login --tenant “<company>.onmicrosoft.com” runs MFA authentication but denies access to artifacts.
This only started happening when I updated to latest az and devops. az-cli 2.0.75 devops 0.13.0. I am the owner of the feed I am trying to access so it should be fine.
If I set the $env:AZURE_DEVOPS_EXT_PAT to my PAT the command works just fine.
@yugangw-msft - In our organization we face the same issue:
az login, when using with a MFA-enabled account in AzureCloud (EU), leads toWhen I log in via Browser manually it asks me for MFA, I confirm, re-try with
az loginthen it works. I highly recommend forwarding this issue to AAD/ESTS team as you suggested.Hi,
I too face similar issue. If i try to access my web app outside Microsoft office environment i getting prompted with MFA. But if i try using my application inside MS environment it just asks me basic authentication and allows access. But in this case since i didn’t do MFA when i try to access Azure APIs it throws below error:
err :AADSTS50079: Due to a configuration change made by your administrator, or because you moved to a new location, you must enroll in multi-factor authentication to access ‘797f4846-ba00-4fd7-ba43-dac1f8f63013’.
So everytime i have to clear browser cache, Login via Azure portal which asks for MFA and then access my site. Which is quite painful.
Any help appreciated.
This is an error from AAD server which I shall clarify with service team.
At the same time, in browser, can you log out the portal and run “az login” again? The goal is to clear the old cache associated with non MFA accounts, and force a new authentication flow.
For MFA, you have to use interactive login through
az loginw/o-u. This requirement comes from AAD token service, not CLI.