When trying to authenticate with google cloud CLI, you are prompted to the OAuth2 flow that asks you to login with your google account and approve.
gcloud auth application-default login
However, this does not work via WSL on windows. It seems that the google CLI tool can't identify the browser that is configured to run on the host.
The flow itself can still work, as the CLI prints a URL that can be copied to the browser, but as a developer, I always prefer being lazy and save a bit more time whenever possible :)
TL;DR
Install wslu and run the command with
DISPLAY='ANYTHING'Why does this work?
There are two steps to solving this problem:
gcloudto work with our settingAfter digging around the python CLI implementation, I found this piece of code inside
check_browser.pyAn easy solution that works for me is running the gcloud CLI with the environment variable
DISPLAY='X':You can also set an alias:
Troubleshooting
However, this might now work on all systems. Also the code might change in the future. If Anyone else is interested in tweaking with it in a different manner, I located the relevant file under:
And you can playaround with it in python