Azure / Azure/azure-cli

`az login` cannot open web browser on WSL2 + Ubuntu 22.04

Open
#27,879 16 comments 16 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad act-platform-engineering-squad Auto-Assign Azure CLI Team Installation question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Describe the bug**
`az login` cannot open web browser on WSL2 + Ubuntu 22.04.

Upstream issues:

- https://github.com/microsoft/WSL/issues/8892
- https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/625

**To Reproduce**

With `xdg-utils` installed:

```
$ sudo apt install xdg-utils
$ az login
A 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`.
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: google-chrome: not found
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening 'https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=04b07795-8ddb-461a-bbee-02f9e1bf7b46&...'
```

Without `xdg-utils` installed:

```
$ sudo apt remove xdg-utils
$ az login
A 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`.
gio: https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=04b07795-8ddb-461a-bbee-02f9e1bf7b46&...: Operation not supported
```

**Additional context**
Windows Terminal supports Ctrl+Click to open hyperlinks, so the user can Ctrl+Click the URL shown in the error to open the web browser and the rest steps work as usual.

Some workarounds are provided in https://github.com/microsoft/WSL/issues/8892 such as installing `wslu`.

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.