Home > Back-end >  Google Sign in returns to login after account selection
Google Sign in returns to login after account selection

Time:07-24

Google Sign in is working on ios (published) but doesn't work in release on Android. On hitting the button the Sign in process is started and you can select an account but after selection of the right account it just return to the login.. nothing happens... However on my emulator it does work. -_-`.

I checked SHA-1 and SHA-256 (release-keys) and updated the google-service.json file.

  signWithGoogle() async {
    final googleSignin = GoogleSignIn(scopes: ['email']);
    final GoogleSignInAccount? googleUser =
    await googleSignin.signIn();
    final GoogleSignInAuthentication googleAuth =
    await googleUser!.authentication;
    final GoogleAuthCredential credential = GoogleAuthProvider.credential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    ) as GoogleAuthCredential;
    final res = await FirebaseAuth.instance.signInWithCredential(credential);
    await FirebaseFirestore.instance.collection('Users').doc(res.user!.uid).set({
      'name' : res.user!.displayName,
      'email': res.user!.email,
      'uid': res.user!.uid,
      'image': res.user!.photoURL,
    }, SetOptions(merge : true));
    return res.user;
  }

I'm using google_sign_in package.

CodePudding user response:

There are 2 sets of sha keys. When you upload an app bundle google signs an apk. This key needs to be updated in firebase.

You have to copy keys from app sign in key section. The release jks's keys is named here as upload key certificate.. use the app sign in key's sha 1 and sha256 in firebase and download the json. Add it to the app and reupload. This should work as expected

preview

  • Related