Firebase login in docker toolbox
The exercise is trying to resolve the Firebase login callback issue in docker; my system setup is VirtualBox with Docker toolbox.
Let’s start with the login command:
# firebase login
Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=5635aa84335869-fgrhgmd47baqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=547585715&redirect_uri=http%3A%2F%2Flocalhost%3A9005
Waiting for authentication…
Then I copy the long URL, and paste it to a browser window in host machine, allow the FirebaseCLI access, the authentication is working fine, but failed at callback. That is due to the setup is docker with VirtualBox, so localhost is not same as the docker machine, which in my case is 192.168.99.100, and HTTP://localhost:9005 is not accessible. If I try to modified the URL with replacing the localhost with docker machine IP, a 400 OAuth2 error will be returned.
Error: invalid_request
device_id and device_name are required for private IP: http://192.168.99.100:9005
After some trying, and managed to get it working with steps below,
- Copy the long URL and paste it to a browser window in host machine
- Follow the steps to complete the authentication
- The callback failed with URL HTTP://localhost:9005?state=…..
- Replace localhost with the docker machine IP in the URL and click enter
Now you will receive a successful message in the browser window and docker terminal.