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

后端 未结 3 1346
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 15:04

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

相关标签:
3条回答
  • 2021-02-05 15:45

    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 be automatically used.
    2. Run all commands with --token <token> flag in your CI system.
    0 讨论(0)
  • 2021-02-05 15:52

    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.

    0 讨论(0)
  • 2021-02-05 15:53

    Firebase respects your standard GCP Oauth2 token.

    Having to go to the browser and get the code doesn't seem very CI or headless.

    This is working for us:

    export GOOGLE_APPLICATION_CREDENTIALS=key.json # Where key.json is your service account json file

    export FIREBASE_TOKEN=$(gcloud auth application-default print-access-token)

    0 讨论(0)
提交回复
热议问题