What is the purpose of firebase-admin?

I have an ember app using firebase as a database. At some point I need my nodejs server to authenticate in order to read / write to the database.

If I don't need authentication, I can simply do the following:

firebase = require('firebase')

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

// Do Server Stuff

      

But when I need authentication, I found two ways to work. They both use the admin-sdk private key. So, the first thing I did was:

Case 1

admin = require('firebase-admin')

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

// Do Server Stuff

      

And it worked. But later I read here that this is fine too.

Case 2

firebase = require('firebase')

firebase.initializeApp(apiKeys.adminConfigGetter()); 

// Do Server Stuff

      

Both give my server the authentication I need, but one of them uses require('firebase-admin')

while the other only firebase = require('firebase')

. So I'm just wondering: If I have all the authentication rights I need using Case 2 , then what is the benefit of using Case 1 ? Does Firebase-Admin provide anything other than privileges?

Thank!

+3


source to share





All Articles