flutter - Google SignIn with firebase in flutter Exception PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
问题描述
我正在尝试使用 Firebase 的 googleSignIn。我的应用程序已经与 Firebase firestore 连接,并且可以完美地进行读/写(Crud)操作。现在我想集成 GoogleSignIn 。但是我遇到了一个未处理的异常。我尝试了一个这个平台答案和 Github 的大量解决方案,但不幸的是,它们都不能解决我的问题。
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)
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);
解决方案
如果您还没有这样做,请尝试将SHA1添加到 Firebase 项目。
这是代码 10 异常。出现“sign_in_failed”错误。您可以在此处获得一份报告,其中包含有关设置 SHA1 的相同说明。
推荐阅读
- css - 无法从我的组件访问全局 SASS 变量
- javascript - 如何使用从 MySQLi 数据库中提取的php 地址在模态负载上加载谷歌地图
- snowflake-cloud-data-platform - 无法使用 Sqitch 连接到 Snowflake
- php - 为什么我的提交按钮没有提交到 mySQL?
- arrays - 遍历动态创建的数组
- windows - Windows 10 上的 linphone-desktop 编译错误
- java - 使用 TextView 制作像素矩阵
- mysql - MySQL快速检索每组中的最后一条记录
- excel - Excel VBA宏dir()函数在文件夹为空时返回值不正确
- node.js - MongoDB NoSQL 注入 - Node.js