- Firebase Tutorial
![App App](/uploads/1/1/7/5/117513184/995137806.jpg)
Sidenote: If you noticed the little avatar icon in the top left corner, that’s the profile picture of the Facebook user I’ve logged in with. Before the player logs in, the Facebook logo is displayed instead. When she clicks the logo, the Facebook login page is displayed and she’s prompted to grant the sample app permission to post on her behalf. Create an account or log in to Facebook. Connect with friends, family and other people you know. Share photos and videos, send messages and get updates.
- Firebase Useful Resources
- Selected Reading
In this chapter, we will authenticate users with Firebase Facebook authentication.
Step 1 - Enable Facebook Auth
We need to open Firebase dashboard and click Auth in side menu. Next, we need to choose SIGN-IN-METHOD in tab bar. We will enable Facebook auth and leave this open since we need to add App ID and App Secret when we finish step 2.
Unity Game Dev Tutorial
Step 2 - Create Facebook App
To enable Facebook authentication, we need to create the Facebook app. Click on this link to start. Once the app is created, we need to copy App ID and App Secret to the Firebase page, which we left open in step 1. We also need to copy OAuth Redirect URI from this window into the Facebook app. You can find + Add Product inside side menu of the Facebook app dashboard.
Choose Facebook Login and it will appear in the side menu. You will find input field Valid OAuth redirect URIs where you need to copy the OAuth Redirect URI from Firebase.
Step 3 - Connect to Facebook SDK
Copy the following code at the beginning of the body tag in index.html. Be sure to replace the 'APP_ID' to your app id from Facebook dashboard.
Example
Let us consider the following example.
Best Unity Tutorial
Step 4 - Create Buttons
We set everything in first three steps, now we can create two buttons for login and logout.
index.html
Step 5 - Create Auth Functions
![Unity game dev tutorial Unity game dev tutorial](/uploads/1/1/7/5/117513184/179662027.jpg)
This is the last step. Open index.js and copy the following code.