6

I followed the steps described in the official GitHub tutorial for use the Firebase CLI (Command Line) with a CI system (simple OS without browser integrate). I use my PC to login in firebase and get the token (from the browser procedure). I copied the token on the other system and I passed the token in all command but it does not work. I get the message that I need to be authenticate for doing these operations:

firebase login 
firebase prefs:token 

copy and use the token in other system

firebase list --token sdfgfdsg...... 

What's the problem?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
cicciosgamino
  • 871
  • 3
  • 10
  • 29

3 Answers3

10

Using a machine with a browser and firebase tools installed, run firebase login:ci --no-localhost and paste the resulting key from the firebase CLI tool into an Environmental Variable and name it FIREBASE_TOKEN (not $FIREBASE_TOKEN).

In your deployment, say

npm install -g firebase-tools
firebase deploy
Ronnie Royston
  • 16,778
  • 6
  • 77
  • 91
  • 1
    In a shared CI system this is not advised, as anyone who has access to the terminal could run `echo FIREBASE_TOKEN` and have your token. In a closed system this is fine, but not a best practice for most who are trying to use this for production CI systems. – TallOrderDev Jun 01 '20 at 23:25
  • So how to automate login in CI without using environment variables at all? "anyone who has access to the terminal" can do everything such as browse source code and more. Disable terminal login at all, or limit terminal login users via appropriate SSH keys must be more practical solution for this. – Kazuya Gosho Aug 13 '21 at 06:16
  • You may add variable into CI environment variables (CircleCI has this) - in that case it's not possible to see it's value, while it's accessable from the environment. – Myroslav Jan 05 '23 at 13:20
5

Make sure not to run firebase logout on your PC, as doing so will invalidate the token (we're working on making this clearer now, actually).

If not, make sure that you're quoting the token:

firebase list --token '-K.....|.....'

The characters included in the auth token may cause shell errors that prevent the command from completing properly if it's not quoted.

Michael Bleigh
  • 25,334
  • 2
  • 79
  • 85
0

I was facing the same problem with Travis, and the problem was the encryption of the token used by travis, you have to ensure you have correctly escaped the pipe symbol inside the token. in my case something like travis encrypt 'FIREBASE_TOKEN=-jksdjksjksdj\|ksdkjsjk'

Hope this helps, because I can ensure you that if you do:

firebase deploy --token '-jksdjksjksdj|ksdkjsjk'

in Travis it just works. firebase is not recognizing the token in your case for some reason, you need to find that reason

Check this out: http://docs.travis-ci.com/user/encryption-keys/

Sloppy Lopez
  • 51
  • 1
  • 3