I am facing a weird issue using GoogleSignIn plugin, I have not used Google signin for a couple of months now, and I decided to re-wire it again today when I faced this issue.
I am using the following test code
google_sign_in: "^1.0.1"
firebase_auth: "^0.2.3"
import 'dart:async';
import "package:flutter/material.dart";
import "package:firebase_auth/firebase_auth.dart";
import "package:google_sign_in/google_sign_in.dart";
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn _googleSignIn = new GoogleSignIn();
_testSignInWithGoogle() async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final FirebaseUser user = await _auth.signInWithGoogle(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
print (googleUser.displayName);
return (user);
}
class TestSignIn extends StatefulWidget {
@override
_TestSignInState createState() => new _TestSignInState();
}
class _TestSignInState extends State<TestSignIn> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("test"),
),
body: new Column(
children: <Widget>[
new FlatButton(onPressed: ()=>_testSignInWithGoogle(), child: new Text("Test SignIn Google"),),
//print user
],
)
);
}
}
md5-479999e22daf708410ceaf35566d1955
E/flutter (13210): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (13210): PlatformException(status, Status{statusCode=DEVELOPER_ERROR, resolution=null}, null)
E/flutter (13210): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:514)
E/flutter (13210): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:154)
E/flutter (13210): <asynchronous suspension>
E/flutter (13210): #2 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:156)
E/flutter (13210): <asynchronous suspension>
E/flutter (13210): #3 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:180)
E/flutter (13210): #4 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:237)
E/flutter (13210): #5 _testSignInWithGoogle (package:full3/TestSignIn.dart:12)
E/flutter (13210): <asynchronous suspension>
E/flutter (13210): #6 _TestSignInState.build.<anonymous closure> (package:full3/TestSignIn.dart:47)
E/flutter (13210): #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:323)
E/flutter (13210): #8 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:375)
E/flutter (13210): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102)
E/flutter (13210): #10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161)
E/flutter (13210): #11 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94)
E/flutter (13210): #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315)
E/flutter (13210): #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73)
E/flutter (13210): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101)
E/flutter (13210): #15 BindingBase&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143)
E/flutter (13210): #16 BindingBase&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121)
E/flutter (13210): #17 BindingBase&SchedulerBinding&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101)
E/flutter (13210): #18 BindingBase&SchedulerBinding&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64)
E/flutter (13210): #19 BindingBase&SchedulerBinding&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48)
E/flutter (13210): #20 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:105)
E/flutter (13210): #21 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:63)
D/EGL_emulation(13210): eglMakeCurrent: 0xa9205720: ver 3 0 (tinfo 0x946fc060)
I do not think this problem if from Firebase side. Firebase is correctly configured with my app and works fine with username/password.
Per discussion in Gitter, this was caused by a SHA mismatch.
And how to tackle this SHA mismatch? @killermonk
@gsunit the accepted answer here, basically: https://stackoverflow.com/questions/39144629/how-to-add-sha-1-to-android-application
You are signing your application with a certificate that Firebase/Google does not recognize. So you either need to add the certificates signature, or change the certificate you are using.
Most helpful comment
Per discussion in Gitter, this was caused by a SHA mismatch.