Implement Firebase Authentication, Google Sign-in, in Flutter.

Implement Firebase Authentication, Google Sign-in, in Flutter.

Implementing Firebase in Flutter is a straightforward process, you install firebase core, config it and then install Firebase Authentication. However, in my experience, I found documentation is a separate piece that I have to connect I have to connect them myself. I will list the step I took and links to official/unofficial docs to implement and solve problems I found in this article.

Content

  1. Install Firebase Core

    • Configure Firebase for your flutter project
  2. Install Firebase Auth and implement it with Riverpod.

  3. Implement Google Sign-in

    • Fix an error on debug version of Android.

Install Firebase Core

  • Install Firebase core and init firebase project in Flutter.

    • The first guide to follow: https://firebase.google.com/docs/flutter/setup?platform=ios

    • Problem found when running: flutterfire configure

      • Flutterfire not found. Need to specify a new path.
    • flutterfire configure will generate config files for each platform.

      • need to run again whenever adding a new platform or adding more firebase packages.

Installing firebase auth.

https://firebase.google.com/docs/auth/flutter/start


Implement sign-in with google.

  keytool -list -v \
  -alias androiddebugkey -keystore ~/.android/debug.keystore
  • Then add debug keys from the result to SHA certificate fingerprint for Android application in Firebase. The app now sign-in successfully with Google on debug version of Android.

The most tedius process for me was to figure out what was the real problem that the error occurs. As the requirement is not clearly state in google_sign_in package but in google play service clieth auth guideline which is right. However a link as useful resources in pacakge would save so much time from googling. Hope this article helpful for who might try implementing Firebase Auth for very first time. Cheers!