Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

I keep getting this error Please run 'az login' to setup account. Using hyper as terminal client #4618

Closed xtianus79 closed 3 years ago

xtianus79 commented 7 years ago

Description

when trying to use az login and then running a cli command I get this

I keep getting this error Please run 'az login' to setup account.

I have signed in 100 times

this might be the cause by I am using hyper


Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
installed via Ubuntu for windows

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: 2.0.18-1

OS Version: What OS and version are you using?
Answer here: windows 10

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: Ubuntu upgraded to 16 bash.exe

yugangw-msft commented 7 years ago

Are you seeing anything when run az account list? It is possible that the credential used to login has no subscriptions. Terminal client type should not matter.

yugangw-msft commented 7 years ago

Please reactivate with more details

francisco-andrade commented 6 years ago

Hi @yugangw-msft , I'm facing the same message here. Can you help me, please? I'm trying to use the client from an Azure CentOS VM.

"az account list" outputs:

Please run "az login" to access your accounts. []

"az login" outputs:

To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code 10CHARCODE to authenticate. # I go to the browser and authenticate then the cli shows: Unexpected polling state invalid_request

The client works from my notebook, but I needed to use the cli from an Azure VM.

CLI Version: What version of the CLI and modules are installed? (Use az --version) Answer here: azure-cli (2.0.24)

OS Version: What OS and version are you using? Answer here: CentOS Linux release 7.4.1708 (Core)

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows) Answer here: bash

Thanks

SebastianM86 commented 6 years ago

We would also be highly interested in the solution if there is one ...

thanks!

yugangw-msft commented 6 years ago

This is the same with #6095

tjprescott commented 6 years ago

Ah, if it is a dupe I will close it again.

bytesemantics commented 4 years ago

Same error - I signed up to Free trial subscription. I can login from browser, and Account Center indicates I have 1 subscription active ('Free trial').

But AZ Cli (installed in Opensuse Tumbleweed using sudo zypper) and using bash shell from 'portal.azure.com' - both report the same error: 'Please run az login to setup account'

jiasli commented 4 years ago

@bytesemantics, could you run az login --debug and share the result to me jiasli at microsoft.com?

At the same time, could you check if there is anything in ~/.azure/azureProfile.json?

bytesemantics commented 4 years ago

I was tempted to ask for this issue to be closed. I was using Chrome, and having read a linked ticket talking about Chrome and MFA issues, I thought I'd try Firefox. Logged in successfully in Firefox and noticed the Auth flow was different to chrome.

Restarted Chrome and logged in successfully.

I can understand this may not be easy to replicate - But from an end users perspective (particularly someone who is evaluating Azure as an alternate to GCP/AWS) - this is not something we should experience and Tech team need to solve it.

jiasli commented 4 years ago

Glad to know it is solved.

Usually, this is caused by outdated AAD cache in Chrome. In such case, az login will show a warning then continue with the next tenant or exit, instead of raising an error:

https://github.com/Azure/azure-cli/blob/c508fa4aa181872c2ed2c7f53712e9d329d7a3f6/src/azure-cli-core/azure/cli/core/_profile.py#L901-L913

As it is hard to reproduce, it is also difficult for us to get the server-side error. It'll be great if you can share the warning message when you see it. It will help us refine the client-side message. Thanks!

JCCChris commented 3 years ago

I get this error and using firefox does not fix it. I also am not allowed to share logs.

jiasli commented 3 years ago

@JCCChris, could you try cleaning the browser cache? If the issue persists, do you mind sharing the --debug log to jiasli at microsoft.com?

JCCChris commented 3 years ago

Using incognito mode worked. It seems like a problem with microsoft identity with cacheing unrelated to chrome or firefox. Both were affected. On previous attempts in both browsers, it did not ask for multifactor authentication.

jiasli commented 3 years ago

Hi @JCCChris, does clearing the browser cache fix this issue? I believe clearing the cache does the same thing as using incognito mode.

siluok3 commented 3 years ago

In my case after logging in with az login --allow-no-subscriptions I was able to log in successfully and see my users details with az account list

simran8282 commented 2 years ago

I was tempted to ask for this issue to be closed. I was using Chrome, and having read a linked ticket talking about Chrome and MFA issues, I thought I'd try Firefox. Logged in successfully in Firefox and noticed the Auth flow was different to chrome.

Restarted Chrome and logged in successfully.

I can understand this may not be easy to replicate - But from an end users perspective (particularly someone who is evaluating Azure as an alternate to GCP/AWS) - this is not something we should experience and Tech team need to solve it.

simran8282 commented 2 years ago

Yes. This works. I tried it on Firefox incognito mode.

bkoprivica commented 2 years ago

Is there a normal solution to this bug?

bkoprivica commented 2 years ago

This is a showstopper, a red flag item. Everything depends on this, IaaC everything.

jiasli commented 2 years ago

@bkoprivica, please open a new issue and share more info by filling the issue template.

Strongpikin commented 2 years ago

It's surprising how after more than 4 years, microsoft has still not fixed this issue/bug. I've lost 3 hours of work time tonight and the issue has still not gone away. I have cleared my cache and tried all the other "fixes" suggested, yet here I still am like Groundhogs Day. Lawd!!!!!

oliviermbida commented 2 years ago

Petition to stop someone closing an issue unless they have clearly posted the steps to resolve the issue. (In the same issue tracker) The commentary on these sorts of issues is always someone posting I will escalate to who ever and then coming back to post I will close the issue. Long gone are the days when it was customary for the user who reported the issue to be the one to confirm that it has been fixed. This bug is still there today using az cli version 2.39.0 , after so many years yet someone has put a close badge on it and probably got paid to do so.

mjqlawson commented 1 year ago

FWIW -- I was having the same problem in an Azure VM. Turned out it was user error. I was using Ctrl+C to copy the device code from my ssh session which, of course, stops the az login process while copying the code. So, az login wasn't listening for the response and the login process didn't complete.

JRisp1 commented 7 months ago

Im having this issue as well. When I attempt to run 'dotnet run --interactive' I am receiving the error "Could not run xxx. Maybe your Azure credential needs a refresh with 'az login'". I then input 'az login' which redirects me to the azure login page on my browser, I login and my az account list runs in the terminal. I then run 'dotnet run -interactive' again and am met with the same error "Could not run xxx. Maybe your Azure credential needs a refresh with 'az login'".

Any recommendations would be appreciated.