Firebase Authentication


#1

Hello-
I have been using Firebase in my Agent code to post updates to a Firebase Realtime Database. Everything works when I have the auth rules in my database set to allow public access to the database. However, I am struggling to setup the Auth Key within the Firebase.class.nut:2.0.0 library to enable Authorized reads and writes.

Based on the Firebase documentation I have created a Service Account for my Agent to access Firebase. I am given a JSON file with my access credentials but I cannot figure out if this will work the the Firebase library. Do I specifically use the private_key field in the library or the entire JSON file?

Does anybody know how to add authorization into the Firebase library using a Service Account? Do I need to create a different type of access token?

Thank you!


#2

I struggled with the same issue and I think I finally found the solution in this post. Go to https://console.firebase.google.com/project/[your-project-id]/settings/database, hover over the bottom part of the Database Secrets dialog and click Show. You will get a token that should work with the Firebase library - I haven’t tested that yet but it worked sending data using Postman so I assume it will work with the library as well.

Hope this helps.


#3

Thank you very much! This absolutely worked with the library and the IDE. I guess the library is using the legacy token authentication method for Firebase. It seems that the authentication process changed significantly when Firebase was integrated completely with Google’s cloud solutions earlier this year.


#4

Just to close the loop on this:
Correct, the Firebase authentication scheme has changed and the current version of the Firebase integration uses the now deprecated method. We are working on adding the new authentication support into the Electric Imp platform and updating the Firebase integration library accordingly. Will post to https://electricimp.com/docs/libraries/webservices/firebase/ when available.
Thanks


#5

Have there been any updates on the authentication scheme?