Do you remember? In the Episode 1, we saw how to create your Firebase project and your Google OAuth 2.0 and Facebook OAuth 2.0 applications. So this is the right time to use the IDs and Secrets you generate in the previous step. 😀

In OAuth 2.0 login and token request, we use a scope variable (that can be a multiple scopes string). For the need of this tutorial, we just ask for basic information, but you can do more than that. Just take a look at the scopes allowed by the systems you are using.

OK. First, we are creating the object that we push in Firebase database. This is the profile of the user that logged in. We have some different fields as we use Google or Facebook (or another OAuth 2.0 compliant system provider).

Then we create the JWT (JSON Web Token) that will be used to secure our communication with Firebase Servers.

What next? Let’s play a little bit more…

With this episode, you are able to :

Login with OAuth 2.0

Get your user profile

Write it to your Firebase Database

So… What next? We will play a little bit more with this and try to geolocalize a phone, choose a Pokémon name in a list and write this information in our Firebase Database in order to put a marker on a map.

I hope everything is clear. Do not hesitate to re-read this episode to let things be clearer.

PAY ATTENTION !! In fact, this is a very bad practice to incorporate your Firebase Secret Key in an application that can be easily decompiled (and SWF can be reversed). This exercise is just meant to show that use of the REST service firebase is possible from AS3. Acquire JWT from Firebase server (or your own server) remains the best option and can be easily achieved through a simple HTML page using the Web SDK Firebase and a WebView.