小编Chi*_*gad的帖子

Flutter:使用 google_sign_in 时出现 PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

我已按照此处的所有步骤进行操作,还在 firebase 控制台中添加了 SHA1 密钥。

这是我的代码

void handleGoogleSignIn() async {
   String errorMessage = "success";

   GoogleSignInAccount _googleSignInAccount = await _googleSignIn.signIn();
   GoogleSignInAuthentication googleSignInAuthentication =
   await _googleSignInAccount.authentication;
   AuthCredential _credential = GoogleAuthProvider.getCredential(
       idToken: googleSignInAuthentication.idToken,
       accessToken: googleSignInAuthentication.accessToken);
   try {
     AuthResult _authResult = await _auth.signInWithCredential(_credential);
   } catch (error) {
     switch (error.code) {
       case "ERROR_INVALID_CREDENTIAL":
         errorMessage = "Invalid credentials";
         break;
       case "ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL":
         errorMessage = "This accouont exists withother credentials";
         break;
       case "ERROR_OPERATION_NOT_ALLOWED":
         errorMessage = "Signing in with Email and Password is not enabled.";
         break;
       default:
         errorMessage …
Run Code Online (Sandbox Code Playgroud)

android firebase google-signin flutter

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

firebase ×1

flutter ×1

google-signin ×1