I am attempting to use firebase-tools
on a remote Linux server via Putty. There is no desktop running on this server.
When I run firebase login
, I'm presented with a long url that I need to copy/paste into any other device's browser:
https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxx.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=3kkd93kl&redirect_uri=http%3A%2F%2Flocalhost%3A9005
I copy/paste this into the browser on my local machine, then I authenticate with my Google account, then it attempts to redirect me to
http://localhost:9005/?state=25744816&code=4/mz.....
which is not an actual server running on my machine and is defintely not the address to the remote machine, which doesn't even have port 9005 active.
So the result is that the terminal is still sitting at "Waiting for authentication..."
I see a command called login:ci
which says its for non-interactive environments, but it appears to do the same thing as the login
command.
How do I get around this issue?
Windows. Download the standalone binary for the CLI. Then, you can access the executable to open a shell where you can run the firebase command. Use npm (the Node Package Manager) to install the CLI and enable the globally available firebase command.
Run firebase tools --version to check version. And as per the prompt, run npm install -g firebase-tools to update. You're right.
You can use Firebase Authentication to allow users to sign in to your app using one or more sign-in methods, including email address and password sign-in, and federated identity providers such as Google Sign-in and Facebook Login.
You can use firebase login --no-localhost
It will then prompt a url you can visit from any browser (no matter the machine), like your host.
Log in with your Google account as usual and accept the permission request.
Finally, copy the provided authorization code
And paste it back in your remote machine's terminal. You should get a success message.
Procedure on how to setup Firebase for CI and headless servers is described here: https://github.com/firebase/firebase-tools#using-with-ci-systems
The Firebase CLI requires a browser to complete authentication, but is fully compatible with CI and other headless environments.
- On a machine with a browser, install the Firebase CLI.
- Run firebase
login:ci
to log in and print out a new refresh token (the current CLI session will not be affected).- Store the output token in a secure but accessible way in your CI system.
There are two ways to use this token when running Firebase commands:
- Store the token as the environment variable
FIREBASE_TOKEN
and it will be automatically used.- Run all commands with
--token <token>
flag in your CI system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With