[英]Google sign_in_failed error in a Flutter app using firebase auth
I'm developing a Flutter mobile app and testing things on an Android emulator.我正在开发 Flutter 移动应用程序并在 Android 仿真器上进行测试。
I'm using Firebase to handle auth logic.我正在使用 Firebase 来处理身份验证逻辑。
I created a service我创建了一个服务
class AuthService {
Future<void> googleLogin() async {
try {
final googleUser = await GoogleSignIn().signIn();
if (googleUser == null) return;
final googleAuth = await googleUser.authentication;
final authCredential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken
);
await FirebaseAuth.instance.signInWithCredential(authCredential);
} on FirebaseAuthException catch (e) {
// handle the error
}
}
}
that I call on the press of a button.按下按钮即可调用。 I do authenticate with my Google account, however, then the terminal shows this error但是,我确实使用我的 Google 帐户进行身份验证,然后终端显示此错误
PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)
I read online that this is due to missing SHA
credentials in my firebase project.我在网上看到这是由于我的 firebase 项目中缺少SHA
凭据。 So I generated these credentials using ./gradlew signingReport
from the android
directory within the project.因此,我使用项目中android
目录中的./gradlew signingReport
生成了这些凭据。 I then added the certificates (both SHA-1
and SHA-256
to the android app in my flutter project.然后,我将证书( SHA-1
和SHA-256
都添加到了 flutter 项目中的 android 应用程序中。
I downloaded again the Google services file provided by Firebase, run flutter clean
and flutter run
but I'm still facing the very same issue when I try to login.我再次下载了 Firebase 提供的 Google 服务文件,运行flutter clean
和flutter run
,但是当我尝试登录时仍然面临同样的问题。
Why is this happening?为什么会这样? Am I missing anything?我错过了什么吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.