-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Profile] az login
: Fall back to device code flow in GitHub Codespaces
#27443
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
Add specific logic to fallback to device code in GitHub Codespaces |
d7553e6
to
352a6d9
Compare
352a6d9
to
d65cd93
Compare
Tests are finally green 🙂 |
@sinedied, thanks for your contribution. Device code has some known limitations with Conditional Access policies (#16401), so we prefer users to use auth code flow. See https://learn.microsoft.com/en-us/cli/azure/microsoft-graph-migration#graph-command-fails-with-aadsts50005-or-aadsts53000 Also, as users can use |
az login
: Fall back to device code flow in GitHub Codespaces (#20315)
az login
: Fall back to device code flow in GitHub Codespaces (#20315)az login
: Fall back to device code flow in GitHub Codespaces
@jiasli sorry for the delay, I missed the notification last week. My last update I received by mail was that you weren't going to merge it, but if this has changed please reopen this PR and I'll get it updated today |
Co-authored-by: Jiashuo Li <4003950+jiasli@users.noreply.github.com>
I have verified the PR works as expected in GitHub Codespaces: Testing steps:
|
Are you using a local VS Code to connect to Codespaces? I can indeed get it working as VS Code automatically maps This is also documented at https://docs.github.com/en/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace#using-command-line-tools-and-rest-clients-to-access-ports
No, this can't be done. This explained in #20315 (comment). |
BTW, I encountered a weird issue that the local VS Code somtimes cannot launch a web browser (Edge, Chrome). Instead, it launches a text-based browser in the terminal. This can be triggered by directly running:
|
Yes, we are using local VSCode. Makes sense re: the redirect URL issue and we have been able to get by w/ using VSCode desktop or reverting to the device code method manually.
Just tried this on my end and it immediately opened a browser window, when running on |
FWIW, we are using Codespaces with VSCode extensively, and the old workflow (automatic port forwarding + web browser) was working fine for us. With this fix, we are now discovering that login via device code flow gets somewhat different permissions; in our case breaking For now will be using |
We have the same issue with @tallaxes. Forcing device code login breaks
And if I try to fetch the object ID, I get The workaround with |
Related command
az login
Description
This PR fixes the long standing issue of
az login
not working in GitHub Codespaces (#20315).For that it uses a simple workaround, the same used in the gh CLI: if the
CODESPACES=true
environnement variable is set, it falls back to using a device code login.Testing Guide
az login
-> by default, it should run the web browser loginCODESPACES=true az login
-> it should automatically fallback to device code login. You can also simply runaz login
in GitHub Codespaces :)