This is the fourteenth part of a journey to build and publish a Flutter™ based app. Now we have an authenticated connected to Google Firebase and its Cloud Firestore database, lets extend our app to do something with it.

Authentication Sign-in providers

Authentication is going to be important for the multiple users of our app to be able to get back to their own stored data each time the app runs. At the moment in testing there are only Anonymous users who willbe supported but won't really be able to do very much until they authenticate. Firebase supports a variety of authentication mechanisms but we need only a few of them to be enabled for our end users. They can be found in the Firebase Concole Choose 'Develop' then 'Authentication' and under the Authentication heading select 'Sign-in method'.

 Firebase Authentication Sign-in providers

There are quite a few, but our app just needs to support a few.

  • Google
  • Phone
  • email
  • Apple

Google Sign-in

Android devices with Google Play (and therefore Google Play Services installed) are pretty well guaranteed to be able to use Google sign-in as an authentication method. iOS users consume google services too so they may well have a google identifier that can be used for authentication. It is a little bit complicated to set up but its worth persevering just to make it easier for Android and Google users to adopt your app.

Generate SHA-1 key

Google Sign-in require the app to provide the SHA-1 of your signing certificate in order to function. To get your SHA-1, follow the instructions to use Keytool or Gradle's Signing Report. there is a lot of technical detail in the Guide to Google APIs for Android. Thankfully, this task can be accomplished straighforwardly inside Android Studio.

  1. Open the app specific build.gradle (android/app/build.grade in Android Studio and find the buildTypes section. Note that by default it has a // TODO item.
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
  2. Select 'Open for Editing in Android Studio' from the flutter commands toolbar at the top of the edit window. Find the 'Gradle' panel and locate signingreport click on it to open.  Android Studio Gradle panel
  3. You should see that the report was successful and your keys were created. Note keystores are pretty important files and should be backed up! Theres a SHA1 value for debug. It needs to be added to the Firebase console.  Android Studio Gradle panel
  4. Select Settings, General, Your apps and add the SHA1 value.
  5. You can check this with the command line too, the password is 'android'.
    $ keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
    Enter keystore password:  
    Alias name: androiddebugkey
    Creation date: Nov 21, 2019
    Entry type: PrivateKeyEntry
    Certificate chain length: 1
    Owner: C=US, O=Android, CN=Android Debug
    Issuer: C=US, O=Android, CN=Android Debug
    Serial number: 1
    Valid from: Thu Nov 21 10:00:45 GMT 2019 until: Sat Nov 13 10:00:45 GMT 2049
    Certificate fingerprints:
    	 Signature algorithm name: SHA1withRSA
    	 Version: 1
  6. Rerun your app and try the google signin. Success looks like this.
    I/FirebaseAuth( 5331): [FirebaseAuth:] Preparing to create service connection to gms implementation
    D/FirebaseAuth( 5331): Notifying id token listeners about user ( xxxxxxxx ).
    D/FirebaseAuth( 5331): Notifying auth state listeners about user ( xxxxxxxx ).
  7. You can verify your user was created in the Firebase Console - look for the G in providers, you'll also have their identifier - their provided email address. Google Authenticated user in Firebase console

The user is set up, but we don't really do anything with it. The sample app prints the UID. Lets implement the other sign-in methods before we come back to