Skip to main content

Authenticate with Firebase Using Facebook Login

To enable Facebook Login in your News App:

Create a Facebook App

  1. First create project for your android application, go to Facebook for Developers
  2. Go to Facebook Quick Start Integrate the Facebook SDK
  3. On the Facebook for Developers site, get the App ID and an App Secret for your app

Configure Firebase

  1. In the Firebase console, open the Auth section
  2. Enable Facebook Login
  3. On the Sign in method tab, enable the Facebook sign-in method and specify the App ID and App Secret you got from Facebook

Facebook Firebase Setup

  1. Make sure your OAuth redirect URI (e.g. my-app-12345.firebaseapp.com/__/auth/handler) is listed as one of your OAuth redirect URIs in your Facebook app's settings page on the Facebook for Developers site in the Product Setting > Facebook Login config

Configure Android App

  1. Add the dependencies for Firebase Authentication and Facebook Login SDK to your app-level build.gradle file:

Facebook Gradle Setup

  1. Create strings for your Facebook app ID and for those needed to enable Chrome Custom Tabs
  2. Open android > app > src > main > res > values > strings.xml file:

Facebook Strings

  1. Open android > app > src > main > AndroidManifest.xml File
  2. Add the following meta-data element and activity for Facebook:

Facebook Manifest

Generate Key Hash

  1. We will use SHA-1 key to generate hashkey for Facebook login
  2. You can generate hash online using Key hash Generator

Hash Key 1 Hash Key 2

Configure iOS App

  1. Create iOS application in Facebook Developer console:

Facebook iOS Setup 1

  1. Add your iOS Bundle ID:

Facebook iOS Setup 2

  1. Copy code shown and paste into Info.plist file:

Facebook iOS Setup 3 Facebook iOS Setup 4