To use authentication, you will need to complete the following initial setup:
- If you plan to use Google Sign-In or Phone Sign-In, you will also need to complete the Google/Phone Sign-In setup.
Skip if you have already enabled authentication while creating a project with a Firebase setup.
To enable authentication in FlutterFlow:
- 1.Open your FlutterFlow project.
- 2.Navigate to the Setting and Integrations () from the Navigation Menu > App Settings > Authentication.
- 3.Turn on the Enable Authentication toggle and select Authentication Type to Firebase.
- 4.To ensure that your users are directed to the appropriate pages based on their login status, you must set the initial pages.
Enabling authentication in FlutterFlow
The user collection stores the information for an authenticated user.
Skip if you have already enabled Create User Collection while creating a project with a Firebase setup.
Use these steps to create the User collection:
- Click on the Firestore from the Navigation Menu (left side of your screen).
- Click on the + Create Collection button.
- Enter a collection_name (this can be anything, but we recommend 'users') and click on Create button.
- If you enter 'users', a popup will open which asks you to populate this collection with default fields. You can click Yes, and we will add all the fields for you.
Creating user collection-1
- If you skipped the previous popup but still want to add default fields, you can:
- Switch to the Settings() tab.
- Find the Users Collection switch and enable it.
- Find the Collection dropdown below, click on the Unset, and select the name of the collection you just created.
- Now switch to the Collection tab(). Now you should see all the default fields.
Creating user collection-2
You do not need to create a password field. This is handled separately by Firebase.
To use the Google/Phone sign-in, you must go through the following steps.
If you aren't planning to use Google/Phone Sign-In, you can skip these steps for now.
An SHA-1 key (also known as the Secure Hash Algorithm) is required if you want to use Google Sign-in and Phone Sign-in. To learn more about the SHA-1 key, see this link.
You can generate the SHA-1 key by entering the following command in your terminal with these steps:
- Open a terminal window:
- Mac: click the Launchpad icon, type Terminal in the search field, then click Terminal.
- Windows: click the Windows icon and scroll down to find the Windows System folder. Open the folder and click or right-click Command Prompt to open it.
- Copy the following command (based on your operating system) and select Enter.
keytool -list -v \
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
If you get the following error while trying the above command:
ERROR:'keytool' is not recognized as an internal or external command
You might not have JAVA installed on your machine. Here is the helpful link to install JAVA and remove the above issue.
keytool -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore
- After enter key password: write android and press enter (you won't see the password while you type in).
Generate SHA-1 key
To add the SHA-1 key in the Firebase Console:
- Open the Firebase console of your project, click on the Gear icon beside the Project overview (Lefthand side panel), and select Project Settings.
- Scroll down to Your App section.
- Select your Android App from the left side menu.
- Find the SHA certificate fingerprints section and click on the Add fingerprint.
- Enter the generated SHA-1 into the Certificate fingerprint input box.
- Click on the Save button.
Adding SHA-1 key in Firebase console
After adding the SHA-1 key, regenerating config files helps you test the Google and Phone sign-in in your device.
To regenerate the config files:
- Return to FlutterFlow. From the Navigation Bar, select Settings & Integrations > Project Setup > Firebase.
- Click on the Regenerate Config Files.
Regenerating config files