azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az login does not work in GitHub Codespaces

Open jongio opened this issue 2 years ago • 23 comments

Describe the bug

az login with default options doesn't work with GitHub Codespaces. It fails when trying to hit localhost on response.

To Reproduce

Open GitHub Codespaces. run az upgrade to get to 2.30 run az login in GitHub Codespaces, the default codespace is fine.

This is printed:

The default web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.

image

**Workaround **

  1. Use --use-device-code option
  2. Detect if user is in Codespaces by checking CODESPACES=true env var and call az login with --use-device-code

Expected behavior

It should work in GitHub Codespaces with default options.

Environment summary

GitHub Codespaces Linux-5.4.0-1062-azure-x86_64-with-debian-bullseye-sid, Ubuntu 20.04.3 LTS Python 3.6.10 Installer: DEB

azure-cli 2.30.0

Additional context

jongio avatar Nov 12 '21 16:11 jongio