使Flutter应用强制用户选择具有FirebaseAuth和GoogleSignInAuthentication的帐户

Wat*_*nan 5 firebase-authentication google-signin flutter

我想强制用户在登录期间选择其帐户之一。有什么办法吗?我还没有找到类似的配置prompt=select_account+consent。

现在,使用这些代码,在用户注销然后再次尝试登录后,它将自动使用所选帐户登录,没有显示窗口供用户选择帐户。

pubspec.yaml

firebase_auth: ^0.8.1+4
google_sign_in: ^3.2.4
Run Code Online (Sandbox Code Playgroud)

登录部分

GoogleSignInAccount googleUser = await _googleSignIn.signIn();
GoogleSignInAuthentication googleAuth = await googleUser.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(
  accessToken: googleAuth.accessToken,
  idToken: googleAuth.idToken,
);
user = await _auth.signInWithCredential(credential);
Run Code Online (Sandbox Code Playgroud)

注销部分

await FirebaseAuth.instance.signOut();
GoogleSignIn _googleSignIn = GoogleSignIn();
await _googleSignIn.signOut();
Run Code Online (Sandbox Code Playgroud)

小智 24

在退出之前使用 GoogleSignInAccount.disconnect() 撤销之前的身份验证:

await _googleSignIn.disconnect();
await FirebaseAuth.instance.signOut();
Run Code Online (Sandbox Code Playgroud)