简体   繁体   English

使用 firebase 身份验证的 Flutter 应用程序中的 Google sign_in_failed 错误

[英]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-1SHA-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 cleanflutter run ,但是当我尝试登录时仍然面临同样的问题。

Why is this happening?为什么会这样? Am I missing anything?我错过了什么吗?

you have to add a support email id in your Firebase console like this您必须像这样在 Firebase 控制台中添加支持 email id

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:Firebase:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Firebase Google登录“未处理的异常:PlatformException sign_in_failed…” - Firebase Google Sign In “Unhandled Exception: PlatformException sign_in_failed…” Flutter:使用 google_sign_in 时出现 PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using google_sign_in PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null, null) 尝试在 flutter 中使用 googleSignIn 时 - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) When trying to use googleSignIn in flutter 无法在 Flutter 中使用 Firebase Auth 进行注册 - Unable to sign up using Firebase Auth in Flutter Firebase Auth Ui Google登录“Developer Error” - Firebase Auth Ui Google Sign In “Developer Error” Firebase使用Google登录身份验证 - Firebase sign in auth with google PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play Flutter: Firebase 电话验证未授权,但谷歌登录成功 - Flutter: Firebase Phone Auth Not Authorized, but Google Sign In Successful 使用 firebase google 登录后,如何在 Flutter 应用程序中保存或保留要在我的设置页面中使用的数据 - How to save or keep data to be used in my settings page after sign in using firebase google sign in, in flutter app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM