在一般有視窗界面的環境下,安裝 google-cloud-sdk 以後執行 gcloud init 的話,gcloud 會自動開啟瀏覽器。但若是在 ssh 或是只有 console 的情況下則會開啟 w3m 或是其他不支援 JavaScript 的瀏覽器,導致驗證失敗。
若要在 console 下執行 gcloud init 可以加上 --no-launch-browser 參數:
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).
You must log in to continue. Would you like to log in (Y/n)? y
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?.......
Enter verification code:
接著在自己的作業系統上開啟瀏覽器,貼上 gcloud 提供的驗證網址,驗證成功以後把代碼貼回 console 中即可完成身份驗證。