Wednesday, 17 May 2017

What is point of firebase-admin?

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!



via Wild dog

No comments:

Post a Comment