Flutter Firebase Authentication Tutorial — Part One

Sabin Khanal
3 min readMay 20, 2021

Authentication is undoubtedly one of the most important feature of any modern application. Firebase makes it really easier for us to add authentication functionality in our app. Here’s a simple guide on how to add Firebase authentication to your app.

If you follow this guide step by step, you don’t need to follow any other tutorials.

  1. Go to https://console.firebase.google.com/u/0/
  2. Hit Add Project Button.

3. Give the project name. Continue. Agree to terms of service. You’ll be landed to the project dashboard.

4. Go to Authentication Menu in the left sidebar.

5. Go to SignIn Method

6. Choose the desired Sign-In provider. Here we are going to choose Google as it’s the most popular login method for android.

7. Go to project settings .

8. Go to Your App Section and Add an android App.

9. Fill in the necessary fields.

For Package Name :

Go to your flutter project and find the app/build.gradle.

There you’ll find the package Name.

For App Nickname,

Fill in anything you want.

For SHA-1 signing cert:

(Although it’s optional for other services, it’s mandatory for consuming authentication services).

Enter the code below in your terminal to get the SHA-1 hash. Copy the hash from the terminal to the signing cert. field.

keytool -list -v -keystore "C:\Users\<YOUR USERNAME>\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Here’s the output of the above command,

10. Fill the form.

You can also add fingerprint later on, from here.

11. Download config file and paste it to android/app/google-services.json.

12. Follow this guide to add necessary imports.

In build.gradle, (project)

classpath 'com.google.gms:google-services:4.3.8'

In- app/build.gradle, add the given code as in the screenshot.

apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:28.0.1')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}

Your preparation is done.

--

--