Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

authentication with Firebase 3.0 in node.js

Because of firebase have upgraded to version 3.0 and i need to migrate to the new version, a problem arose as the authentication of my node server. The code is this

var firebase = require('firebase');

var config = {
  apiKey: "<minha apiKey>",
  authDomain: "<meu domínio de autenticação>",
  databaseURL: "<url do banco>",
  storageBucket: "<minha storageBucket>",
  serviceAccount: "<nome do arquivo gerado pela conta de serviço>.json"
};

firebase.initializeApp(config);

When running npm start, the following error appears:

FIREBASE WARNING: Provided authentication credentials are invalid. 
This   usually indicates your FirebaseApp instance was not initialized
correctly. 
Make sure your apiKey and databaseURL match the values provided for your 
app at 'https://console.firebase.google.com/', or if you're using 
a service account, make sure it's authorized to access the specified 
databaseURL and is from the correct project.

But I got all the settings information on my own console in firebase.

like image 716
alisson oliveira Avatar asked Jan 06 '23 23:01

alisson oliveira


1 Answers

I had the same problem. In my case, it turned out that the underlying cause was that my service account was not a member of the "Editor" role of my project. I had to go to the Google Cloud IAM console (go to the Firebase project console, click on the gear, and click on "Permissions") and create a new service account.

Apparently there was a Firebase bug where some service accounts were created with insufficient permissions. Here is a thread on Google Groups discussing the bug: https://groups.google.com/forum/#!topic/firebase-talk/i2sqxJIRzno

like image 74
Daniel Libicki Avatar answered Jan 08 '23 14:01

Daniel Libicki