[英]google sign in with flutter and firebase auth
I am trying to implement Google Signin in my flutter app and I don't know what I am doing wrong, a little help is appriciated.我正在尝试在我的 flutter 应用程序中实施 Google Signin,但我不知道自己做错了什么,需要一些帮助。
final GoogleSignIn googleSignIn = GoogleSignIn();
GoogleSignInAccount? currentUser;
googleLogin(context, color) async {
try {
final googleUser = await googleSignIn.signIn();
// loading(context, color);
// I am not able to go beyond here
if (googleUser == null) {
Navigator.pop(context);
return;
}
currentUser = googleUser;
String? access, id;
await googleUser.authentication.then((value) async {
if (value != null) {
access = value.accessToken;
id = value.idToken;
}
});
UserCredential userCredential = await FirebaseAuth.instance
.signInWithCredential(
GoogleAuthProvider.credential(idToken: id, accessToken: access));
print('name: ${currentUser!.displayName}');
} catch (e) {}
} }
I am stuck at the line, comment after that, what happens in the app is that dialogue box of accounts for google appears and when I select account, it disappears and nothing happens.我被困在这条线上,在那之后发表评论,应用程序中发生的是谷歌账户对话框出现,当我选择账户时,它消失并且没有任何反应。
As for terminal, it displays至于终端,它显示
An Observatory debugger and profiler on RMX3363 is available at:
http://127.0.0.1:50786/aiMRW_z817c=/
The Flutter DevTools debugger and profiler on RMX3363 is available at: http://127.0.0.1:9101?
uri=http://127.0.0.1:50786/aiMRW_z817c=/
V/OplusZoomWindowDecorViewHelper(24796): setLastReportedMergedConfiguration
mZoomDisplayHeight: 2400 getDecorView.19495807
D/hw-ProcessState(24796): Binder ioctl to enable oneway spam detection failed: Invalid
argument
D/SurfaceComposerClient(24796): VRR [FRTC] client handle [bufferId:18446744073709551615
framenumber:0] [ffffffff, ffffffff]
D/SurfaceComposerClient(24796): VRR [FRTC] client handle [bufferId:18446744073709551615
framenumber:0] [ffffffff, ffffffff]
E/Parcel (24796): Reading a NULL string not supported here.
V/OplusZoomWindowDecorViewHelper(24796): setLastReportedMergedConfiguration
mZoomDisplayHeight: 2400 getDecorView.200652440
D/SurfaceComposerClient(24796): VRR [FRTC] client handle [bufferId:18446744073709551615
framenumber:0] [ffffffff, ffffffff]
V/OplusZoomWindowDecorViewHelper(24796): removeZoomView
I/Quality (24796): Skipped: false 1
A little help is appriciated.需要一点帮助。 Thanks.
谢谢。
I realized I forgot to add SHA1 and SHA256 at firebase, added those and it worked.我意识到我忘记在 firebase 添加 SHA1 和 SHA256,添加了它们并且它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.