1

I am trying to access Realtime Database using the new feature introduced with 3.1.0 release: "The Node.js SDK now supports unauthenticated access. If no service account is provided, Realtime Database access will be restricted just as any unauthenticated client would be."

The SDK is updated to 3.1.0:

user@ha:~/dev/project/auth/firebase$ sudo npm install -g firebase
[sudo] password for user:
/usr/local/lib
└─┬ firebase@3.1.0

Tried with no service account:

var firebase = require('firebase');

console.log('Initialise Firebasse app');
firebase.initializeApp({
    // serviceAccount: "",
    databaseURL: "https://some-valid-firebase.firebaseio.com"
});

The result is:

user@ha:~/dev/project/auth/firebase$ nodejs fb_anon.js
Initialise Firebasse app
/home/user/dev/project/node_modules/firebase/auth-node/auth.js:61
    throw new Error('Invalid service account provided');
    ^

Please help, probably I am missing something obvious here. :-(

FelixEnescu
  • 4,664
  • 2
  • 33
  • 34

1 Answers1

2

What is happening is that your application is referring to an old sdk version that is inside your node_modules. And thats because you updated the firebase sdk with the globally flag and you are referring to a local sdk.

You should be installing it locally to your application. First make sure you added "firebase":"3.1.0" into your package.json file and then call npm install inside the same dir.

I've just tested it with the same piece of code you added and everything went as expected.

In this question you can find some additional information and tips when using npm.

Community
  • 1
  • 1
adolfosrs
  • 9,286
  • 5
  • 39
  • 67