6

I have an ember application using firebase as the database. At one point, I need my nodejs server to have authentication in order to read/write to the database.

If I don't need authentication, I could just do the following:

firebase = require('firebase')

// firebaseConfigGetter() returns my webAPI key and other stuff
firebase.initializeApp(apiKeys.FirebaseConfigGetter()); 

// Do Server Stuff

But when I do need authentication, I found two ways that work. Both of them use the private admin-sdk key. So the first thing I did was this:

Case 1

admin = require('firebase-admin')

// adminConfigGetter returns my private admin-sdk key and other stuff
admin.initializeApp(apiKeys.adminConfigGetter()); 

// Do Server Stuff

And that worked. But later on, I read here that this is also fine

Case 2

firebase = require('firebase')

firebase.initializeApp(apiKeys.adminConfigGetter()); 

// Do Server Stuff

Both give my server the authentication I need, but one of them utilizes require('firebase-admin') whereas the other just does firebase = require('firebase'). So I'm just curious: If I have all the authentication privileges I need by using Case 2, then what advantage is there of using Case 1? Does Firebase-Admin grant me something other than privileges?

Thanks!

Community
  • 1
  • 1
Cameron
  • 2,805
  • 3
  • 31
  • 45
  • 4
    Admin SDKs have different purpose and capabilities than client SDKs. See [this blog post](https://firebase.googleblog.com/2016/11/bringing-firebase-to-your-server.html) for details. – Michael Bleigh May 17 '17 at 19:40
  • @MichaelBleigh Thank you. Something like this is what I was looking for. – Cameron May 17 '17 at 19:50

0 Answers0