Sunday, June 26, 2022
HomeFirebase TutorialsFirebase Facebook Authentication Android Studio

Firebase Facebook Authentication Android Studio

This article describes how to create Firebase Facebook authentication in android studio. If it is the first time to see Firebase tutorials. The article of this link describes how to connect android studio project to Firebase.

Facebook login button is the most preferred, fast and convenient tool for android application users. As you can allow the users to create their accounts and log into your application through multiple platforms. So, in this article we will integrate Firebase Facebook Authentication in Android Studio.

The next steps depending on that your android studio project already connect to Firebase. So, open Firebase Console to enable Facebook Authentication. Then, Click on Authentication and next click on Sign in Methods as showing in the following image.

Add facebook authentication

Then, Click on Facebook in sign in methods to enable it. You will see the requirements to enable Facebook Authentication. You need Facebook App ID and App Secret. As required in the following image.

how to enable facebook authentication

Create a New Facebook App ID

In order to get Facebook App ID and App Secret go to Facebook Developers Website to create a new Facebook App for your android studio project. If it is the first time to visit Facebook Developers website, You will need to create a developer account using your Facebook account. After that click on MyApps then Add New App.

get Facebook App ID and App Secret
add new facebook app

After that you will see the following dialog to create a new App ID and choose how are using your app. So, Select the third option “Every Thing Else”, In order to enable Facebook login. Then Type Your App name and click “Create App ID” Button.

create new app id
create a new app ID

Now, You are ready get the required App ID and App Secret. Just, click on Settings then Basic. You will see the following image.

the required app id and app secret

Copy the App ID then go to Firebase and click enable Button and paste it in The App ID in it`s Field. Then click show App Secret for Facebook App and paste it in Firebase Facebook Authentication and click on Save Changes for Facebook app. Then copy OAuth redirect URI and add it to your Facebook app configuration and click Save Button.

add facebook app id and app secret

The next Step is adding product to your Facebook App. Click on Add Products as shown in the following image. Then click on set up at Facebook Login Card as shown then select the platform, for our project select android platform.

add login product to facebook app

Copy OAuth redirect URI and add it to your Facebook app configuration and click Save Changes Button.

Set Up Facebook Authentication to Android Studio

1- Import Facebook SDK to your Project

The next step is to set up Facebook Authentication in Android Studio. Click on “Next” Button to ignore downloading Facebook SDK as shown.

ignore downloading Facebook SDK

Next, project level gradle file and add the following maven repository to bildscript section.


Then Open module level gradle file and add the following dependency. Then click on sync project and click Next for Facebook to move to the next step.

implementation '[5,6)'

2- Tell Us about Your Android Project Step

In this step, add your android studio package name and Main Activity package name as shown and then click Save button and Continue Button.

add your android studio package name

3- Add Your Development and Release Key Hashes

The following code will generate the Development Key Hash. It is independent on the operating system your are using. Just, Past the following code in oncreate() method of Main Activity. After that run the app. Then, search for “KeyHash: ” in logCat you will get it.

try {
PackageInfo info = getPackageManager().getPackageInfo(
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
} catch (PackageManager.NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {


After that copy the Key Hash and past it the click Save and Continue. as shown in the following image.

4- Enable Single Sign On for Your App

Click on Single Sign On button to enable single sign On if you would like your Android Notifications to have the ability to launch your app. Then click save and continue.

5- Edit Your Resources and Manifest

Follow up the instructions of this step in Facebook Quick Start settings.



Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

KU NUR RASYIDAH BINTI KU BIDE on Custom Calendar View Android | Project Java Files
SHIVANT KUMAR PANDEY on Login And Registration by Firebase
Adriane Troy U. Alariao on Custom Calendar View With Events Android