0

I am trying googleSignIn with Firebase in flutter .My App is Already connected with Firebase firestore and Does Read/Write (Crud) Operations Perfectly.NOw I want to Integrate GoogleSignIn .But I am Getting an Un-handled exception.. I have Tried a tons of Solution of this Platform Answers and Github ,But Unfortunately non of them could solve my problem.

E/flutter ( 2995): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: ,null)

enter image description here

      final GoogleSignInAccount googleSignInAccount = await _googleSignIn.signIn();
      final GoogleSignInAuthentication googleSignInAuthentication =
     await googleSignInAccount.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(
  accessToken: googleSignInAuthentication.accessToken,
  idToken: googleSignInAuthentication.idToken,
);

final AuthResult authResult = await _firebaseAuth.signInWithCredential(credential);
final FirebaseUser user = authResult.user;

assert(user.email != null);
assert(user.displayName != null);
assert(user.photoUrl != null);

name = user.displayName;
email = user.email;
imageUrl = user.photoUrl;

assert(!user.isAnonymous);
assert(await user.getIdToken() != null);

final FirebaseUser currentUser = await _firebaseAuth.currentUser();

assert(user.uid == currentUser.uid);
Alok
  • 8,452
  • 13
  • 55
  • 93
Mehboob
  • 57
  • 1
  • 9
  • On Stack Oveflow, don't show pictures of text. Copy the text into the question and format it so that it's easy to read, copy, and search. – Doug Stevenson Sep 12 '20 at 16:37
  • Couldn't you read the Picture by clicking on it ? – Mehboob Sep 12 '20 at 20:05
  • It's easier for everyone, and the expected convention on Stack Overflow, to copy the text instead of using a picture. If you disagree, I suggest reading through this conversation: https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors – Doug Stevenson Sep 12 '20 at 20:08

2 Answers2

0

Try to add SHA1 to the Firebase project if you haven't done so.

This is Code 10 exception. With "sign_in_failed" error. You can get a report here with same instructions on setting up SHA1.

Alexis
  • 26
  • 5
  • Are you using Google People API by any chance? – Alexis Sep 12 '20 at 20:32
  • no ,, Do i need to Add Google people Api ? if yes then Why I should use it? – Mehboob Sep 12 '20 at 20:40
  • I was simply asking due to [this](https://stackoverflow.com/questions/57776534/platformexceptionsign-in-failed-com-google-android-gms-common-api-apiexception) – Alexis Sep 12 '20 at 20:51
0

I got fixed my Problem,Actually the main problem was due to change of Package name in firebase and in my project.. Previously I used to replace the package name in json file, whenever I had to read and write the data in firebase.Hope this may help someone in future.

Mehboob
  • 57
  • 1
  • 9