How to login to `firebase-tools` on headless remote server?

无人久伴 提交于 2019-12-05 21:41:41

问题


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?


回答1:


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.




回答2:


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.

  1. On a machine with a browser, install the Firebase CLI.
  2. Run firebase login:ci to log in and print out a new refresh token (the current CLI session will not be affected).
  3. 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:

  1. Store the token as the environment variable FIREBASE_TOKEN and it will automatically be utilized.
  2. Run all commands with the --token <token> flag in your CI system.


来源:https://stackoverflow.com/questions/43828039/how-to-login-to-firebase-tools-on-headless-remote-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!