我想登录Google,但是得到了这个错误.我尝试了所有可能的解决方案,比如添加SHA-1,生成客户机ID,发布同意屏幕,但是它仍然给出了这个例外--这里是我的代码片段
Future<AuthCredential?> getGoogleCredential() async {
print('Inside getGoogleCredential');
final GoogleSignIn googleSignIn = GoogleSignIn(
signInOption: SignInOption.games,
scopes: [GamesApi.gamesScope],
clientId: 'client id',
hostedDomain: 'my hosted domain',
);
// print('google Sign in is ${googleSignIn.clientId}');
print('google Sign in is ${googleSignIn.currentUser}');
final GoogleSignInAccount? googleUser =
await googleSignIn.signIn().catchError((error) {
print('Failed to sign in with Google Play Games: $error');
});
print('google User is ${googleUser}');
if (googleUser == null) {
print('Failed to sign in with Google Play Games.');
return null;
}
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
return credential;
}
Future signIn() async {
final AuthCredential? googleCredential = await getGoogleCredential();
if (googleCredential != null) {
await FirebaseAuth.instance.signInWithCredential(googleCredential);
} else {
print('Trying signInAnonymously');
await FirebaseAuth.instance.signInAnonymously();
}
}
发布于 2022-09-24 09:19:05
如果忘记将Google SHA1控制台添加到firebase应用程序设置中,也会发生这种情况。
如何做:
上面添加
理想情况下,您应该在防火墙设置中拥有6个证书。
3 SHA-1 ->(开发/发布/播放控制台)
3 SHA-256 ->(开发/发布/播放控制台)
发布于 2022-06-30 10:20:28
基本上,错误是ApiException: 10。要解决这个问题,您需要在谷歌云控制台上使用SHA1注册应用程序。
转到https://console.cloud.google.com/
单击凭据>创建凭据>OAuth客户端ID
选择希望应用程序在其中工作的平台。
填写应用程序的包名。
为了填写SHA1值,请将命令行和cd打开到主项目文件夹中的android文件夹,然后键入命令./gradlew signingReport,然后按enter。在完成了一些计算之后,您将看到扩展mac地址格式的SHA1值。
如果终端出现错误,将安装支持的java (在回答时,java 14已被支持),并将其路径(包括windows环境变量中的bin文件夹)设置为新路径。
https://stackoverflow.com/questions/72516426
复制相似问题