az login does not work in GitHub Codespaces
- 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`.
```

**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
Assessment
This issue has not been assessed yet.