Azure / Azure/azure-cli

az login does not work in GitHub Codespaces

Open
#20,315 30 comments 7 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**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](https://user-images.githubusercontent.com/2163001/141501665-bfb70a45-2170-461b-8a12-7959c786d02c.png)

**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**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.