4

Google sign in works when testing on the emulator and a real device, however, in production it doesn't work. I have added the SHA 1 key to my Firestore project.

How would I fix this?

Future<User> googleSignIn() async {
    try {
      GoogleSignInAccount googleSignInAccount = await Global.googleSignIn.signIn();
      GoogleSignInAuthentication googleAuth =
          await googleSignInAccount.authentication;

      final AuthCredential credential = GoogleAuthProvider.credential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );
      UserCredential result = await Global.fbAuth.signInWithCredential(credential);
      User user = result.user;
      updateUserData(user);
      return user;
    } catch (error) {
      print(error);
      return null;
    }
  }
        onPressed: () async {
        showDialogue(context);
          var user = await loginMethod();
          if (user != null) {
            hideProgressDialogue(context);
            Navigator.pushReplacementNamed(context, SharedStrings.userInfoPath);
         
signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

       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.release
       }
SK1dev
  • 1,049
  • 1
  • 20
  • 52
  • 1
    You mean to say when application is live on play or app store ? – Shubham Narkhede Dec 18 '20 at 13:48
  • 1
    @ShubhamNarkhede Yeah, my app's just been published and now Google sign in is not working – SK1dev Dec 18 '20 at 13:50
  • 1
    In what way does it not work? Do you get an error message? – S.V. Dec 18 '20 at 13:52
  • 1
    @DrSatan1 After selecting the email address it just stayed on loading – SK1dev Dec 18 '20 at 13:55
  • 1
    I think you need to add Play console SHA 1 key Go to Play console Select Your app -> Setup -> App signing and add this SHA1 key to your firebase account – Shubham Narkhede Dec 18 '20 at 13:55
  • 1
    @ShubhamNarkhede Do I replace the existing key in my firebase project with this new key? – SK1dev Dec 18 '20 at 14:00
  • 1
    no no, Only add one more key don't replace @SK7 – Shubham Narkhede Dec 18 '20 at 14:01
  • 1
    @ShubhamNarkhede Ok cool i've added it and now need to upload a new version to see if it's worked. You can add your comment as an answer if you like and I'll accept it. – SK1dev Dec 18 '20 at 14:04
  • 1
    @SK7 yes before upload the new version please check the existing APK may be it will work now or else go for upload new version – Shubham Narkhede Dec 18 '20 at 14:06
  • 1
    @ShubhamNarkhede I just checked and on my phone it went straight into the app without checking which email and on another phone it still stayed on loading – SK1dev Dec 18 '20 at 14:14
  • 1
    @ShubhamNarkhede So it went straight into the app without asking for the password for the google account – SK1dev Dec 18 '20 at 14:34
  • 1
    @SK7 right, When you use google sign then they do not ask you password. You only need to select gmail account also please share app link or name if possible – Shubham Narkhede Dec 18 '20 at 14:47
  • 1
    @ShubhamNarkhede Ah ok I see. Sure, here's the link: https://play.google.com/store/apps/details?id=com.planetrescue_climatechange – SK1dev Dec 18 '20 at 14:53

1 Answers1

5

After Uploading to play store, Play store generate its own SH1 which we have to replace in second key in google console.

Go to google console>app signing> copy SH1 generate by console. Add that in google sign in console replace it from 2nd key.

ahmad bajwa
  • 966
  • 2
  • 10
  • 30