Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase CLI Authentication through token

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?

like image 968
cicciosgamino Avatar asked Oct 14 '15 14:10

cicciosgamino


People also ask

How do I use Firebase authentication token?

To do so securely, after a successful sign-in, send the user's ID token to your server using HTTPS. Then, on the server, verify the integrity and authenticity of the ID token and retrieve the uid from it. You can use the uid transmitted in this way to securely identify the currently signed-in user on your server.

Does Firebase Auth use JWT?

Firebase gives you complete control over authentication by allowing you to authenticate users or devices using secure JSON Web Tokens (JWTs). You generate these tokens on your server, pass them back to a client device, and then use them to authenticate via the signInWithCustomToken() method.

How do I connect to Firebase command line?

To download and run the binary for the Firebase CLI, follow these steps: Download the Firebase CLI binary for Windows. Access the binary to open a shell where you can run the firebase command. Continue to log in and test the CLI.


2 Answers

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
like image 118
Ronnie Royston Avatar answered Oct 03 '22 19:10

Ronnie Royston


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.

like image 39
Michael Bleigh Avatar answered Oct 03 '22 18:10

Michael Bleigh