Facebook Sign-In
Facebook Sign-In allows users to authenticate using their Facebook Accounts.
Before getting started with this section, ensure you have:
- 1.
- 2.Completed Initial setup required for authentication. (Please note: Skip if you have already enabled authentication and created a 'users' collection while creating your project with Firebase Setup.)
Adding Facebook sign-in comprises the following steps:
- 7.
- 10.
When you create an app on the Facebook Developer Console, you are given a unique App ID and App secret, ensuring secure communication between your app and Facebook's servers. Additionally, it lets you define required permissions and user data access and also restricts login origins for enhanced security.
To create an app on Facebook:
- 1.
- 2.Click on the My Apps (Top menu).
- 3.Click on the Create App button (Top right side of your screen).
- 4.Select 'Allow people to log in with their Facebook account' and click Next.
- 5.Add an app name and click Create app.
Now, you must add and configure platforms that will support Facebook authentication - For example, Android and iOS.
To do so:
- 1.Open the app created in the previous step and navigate to App settings > Basic.
- 2.To support Android app:
- 1.Click the + Add platform button at the bottom, select Android, and click Next.
- 2.Select Android Store on which you'll publish your app and click Next.
- 3.To get Key hashes:
- 1.
- 2.Launch the terminal, paste the copied code, and press enter. To open a terminal window:
- Mac: Use the Launchpad () or press (⌘ + Spacebar) for Spotlight search, type 'Terminal', and open it.
- Windows: Click the Windows icon, navigate to the 'Windows System' folder, and open 'Command Prompt' either by clicking or right-clicking it.
- 3.When it asks to enter keystore password, type android and hit enter.
- 4.Copy and paste the output in the Key hashes input box.
- 4.For Package Names, return to your Flutter project > Settings and Integrations > App Details and copy-paste Package Name.
- 5.For Class Name, paste the package name (obtained from the FlutterFlow project) and then add
.MainActivity
at the end. For example, 'com.flutterflow.yourapp.MainActivity'. - 6.Click Save changes.
- 3.To support iOS app:
- 1.Click the + Add platform button at the bottom, select Android, and click Next.
- 2.Inside the Bundle ID, return to your Flutter project > Settings and Integrations > App Details and copy-paste Package Name.
- 3.Click Save changes.
Configure Android app
Configure iOS app
When users log in using third-party providers (like Google or Facebook), fetching their email addresses reduces the steps they need to take during sign-up. For Facebook sign-in, to access a user's email, you must add email permission in Firebase developer console.
Here's how you do it:
- 1.
- 2.Inside the Authentication and account creation, click Edit.
- 3.Select Add for email.
- 1.
- 2.Click on the Get started button (this may not be visible if you have already set up other forms of Authentication).
- 3.Select the Sign-in method tab.
- 4.Click on Facebook (Under the 'Additional Providers' section). If you have already added any other provider, click on the Add new provider and then click on Facebook.
- 5.Find the Facebook switch and enable it.
- 6.To get the App ID, head to the Facebook Developer Console, open your app and navigate to App settings > Basic. Copy the App ID and paste it into the App ID input box in Firebase.
- 7.Similarly, copy-paste the App Secret.
- 8.Now, In Firebase console, copy the URL below and navigate to the Facebook Developer Console, open your app, select Products > Configure > Settings.
- 9.Inside the Valid OAuth Redirect URIs, paste the URL and click on save changes.
- 10.Return to to Firebase Console and finish the setup by clicking on Save.
To enable the Facebook authentication in FlutterFlow:
- 1.Open your FlutterFlow project.
- 2.Click on the Settings and Integration from the Navigation Menu (left side of your screen).
- 3.Enter the Facebook App Name (name that you entered while creating the app on Facebook) and Facebook App ID (i.e., you App ID).
To allow users to authenticate, you need a login page with a button. You can create your own or use the one from the widget template or page template.
Here's how you can add the Facebook sign-in button from our page template:
When you click the sign-in button, it will trigger the 'Log In' action, prompting users to provide their Facebook credentials.
To add login action:
- 1.Select the widget (e.g., Button) on which you want to add the action.
- 2.
- 3.Search and select the Log in (under Backend/Database > Firebase Authentication) action.
- 4.Set Auth Provider to Facebook.
- 5.Tick the Create User Document and set the Collection to users. After successful login, this will insert the user's email address into the 'users' collection. If a user already exists, it won't add details again.
Facebook Sign-In functionality does not work in Run or Test Mode and can only be tested on a real device or emulator. To deploy and test the Facebook authentication, you will need to download the code and run it in your IDE.
To confirm the successful integration and the creation of users, navigate to your Firebase project > Authentication > Users and check the user entries.

Verify user creation
Last Updated Date: August 28, 2023
Last modified 30d ago