'PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

I've searched the whole internet, tried every possible solution, still I'm not being able to sign in using GoogleSignIn from my flutter app.

Things I've tried :
1. Added SHA-1 Certificate
2. Added SHA-256 Certificate
3. Filled O-Auth Screen
4. Enabled GoogleSignIn in firebase
5. Added support email

Testing currently only in debug mode. As the app is in its initial stages right now I don't want to build a release version yet. Using debug SHA-1 and SHA-256 fingerprints.

Future<FirebaseUser> _signIn(BuildContext context) async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
    await googleUser.authentication;

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

AuthResult userDetails =
    await _firebaseAuth.signInWithCredential(credential);
ProviderDetails providerInfo = 
ProviderDetails(userDetails.user.providerId);

List<ProviderDetails> providerData = List<ProviderDetails>();
providerData.add(providerInfo);

UserDetails details = UserDetails(
    providerDetails: userDetails.user.providerId,
    userEmail: userDetails.user.email,
    userName: userDetails.user.displayName,
    photoUrl: userDetails.user.photoUrl,
    providerData: providerData);

return userDetails.user;
}

Error I get

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 
PlatformException(sign_in_failed, 
com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter (12322): #0      StandardMethodCodec.decodeEnvelope 
package:flutter/…/services/message_codecs.dart:564
E/flutter (12322): #1      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:316
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #2      MethodChannel.invokeMapMethod 
package:flutter/…/services/platform_channel.dart:344
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #3      GoogleSignIn._callMethod 
package:google_sign_in/google_sign_in.dart:218
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #4      GoogleSignIn._addMethodCall.<anonymous closure> 
package:google_sign_in/google_sign_in.dart:27
E/flutter (12322): #5      _rootRun  (dart:async/zone.dart:1120:38)
E/flutter (12322): #6      _CustomZone.run  (dart:async/zone.dart:1021:19)
E/flutter (12322): #7      _FutureListener.handleWhenComplete  
(dart:async/future_impl.dart:150:18)
E/flutter (12322): #8      
Future._propagateToListeners.handleWhenCompleteCallback  
(dart:async/future_impl.dart:609:39)
E/flutter (12322): #9      Future._propagateToListeners   
(dart:async/future_impl.dart:665:37)
E/flutter (12322): #10     Future._addListener.<anonymous closure>  
(dart:async/future_impl.dart:348:9)
E/flutter (12322): #11     _rootRun  (dart:async/zone.dart:1124:13)
E/flutter (12322): #12     _CustomZone.run  (dart:async/zone.dart:1021:19)
E/flutter (12322): #13     _CustomZone.runGuarded  
(dart:async/zone.dart:923:7)
E/flutter (12322): #14     _CustomZone.bindCallbackGuarded.<anonymous 
closure>  (dart:async/zone.dart:963:23)
E/flutter (12322): #15     _microtaskLoop  
(dart:async/schedule_microtask.dart:41:21)
E/flutter (12322): #16     _startMicrotaskLoop  
(dart:async/schedule_microtask.dart:50:5)
E/flutter (12322):


Solution 1:[1]

I know this question was posted quite some time ago but in case anybody else had issues, in addition to all of the above steps, I also enabled Google People API. Make sure that you are on the right email and project.

https://console.developers.google.com/apis/library/people.googleapis.com?q=people&id=5877a7af-1d13-4098-a53e-b5e2d7a87a4f&project=phamton-test

Solution 2:[2]

Did you rebuild the project after adding the dependencies?

Sometimes you need to rebuild your project whenever you add any platform specific plugin before it can be used effectively

Solution 3:[3]

So as regards to this error, if you find yourself facing it at any point.

There are 2 things that could possibly be wrong

  1. Your app is not on the playstore and you're testing locally with a signed app.

  2. You should probably go and add more SHA keys, if you have only SHA-1 go ahead and put SHA-256. Also be weary of your test environment as it could also mean that your apk mode(Testing or Production) is not correlating.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony Pham
Solution 2 Destiny Ed
Solution 3 Denzel