首页 > 解决方案 > Flutter - 我无法使用 Google 帐户登录

问题描述

当您单击该按钮时,会出现一个窗口,其中包含我选择的 Google 帐户,而不是切换到新页面,而是出现错误。截图错误

我的代码:

import 'package:google_sign_in/google_sign_in.dart';

GoogleSignIn googleAuth = GoogleSignIn();
final FirebaseAuth _fAuth = FirebaseAuth.instance;
final GoogleSignIn _gSignIn = GoogleSignIn();

 Future<FirebaseUser> _signInGoogle() async {
    GoogleSignInAccount googleSignInAccount = await _gSignIn.signIn();
    GoogleSignInAuthentication authentication = await googleSignInAccount.authentication;

    var signInWithGoogle = signInWithGoogle;
    FirebaseUser user = await _fAuth.signInWithGoogle(
      idToken: authentication.idToken,
      accessToken: authentication.accessToken
    );
    return user;
  }


onPressed:() async {
  await _signInGoogle();                            
 Navigator.of(context).pushReplacementNamed('/home_screen');
} 

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

标签: androidfirebasedartfluttergoogle-authentication

解决方案


您是否添加了您的 SHA 指纹?

请检查我的答案以了解如何执行此操作:https ://stackoverflow.com/a/54479992/679553


推荐阅读