I am using Firebase auth with Flutter and have implemented google sign in using google_sign_in package version ^5.2.3 I noticed that after signing out, when I clicked sign in again the app didn't prompt me to select which of my google accounts I want to sign in it, instead logging me in with the previous account I had used.
After some research I added the following code in sign out flow
await GoogleSignIn().disconnect();
await FirebaseAuth.instance.signOut();
I was able to sign out, but when I tried to log in again, I got an exception with following message
PlatformException (PlatformException(exception, BAD_REQUEST, null, null))
HOWEVER, if I hot restart app, I am able to sign in and also get the prompt to select a google account I want to log in. The google sign in plugin github doesn't allow issue filing so I can't get help here. Help appreciated.
flutter doctor
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.18362.535], locale en-US)[.] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
X cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for
more details.
[√] Chrome - develop for the web
[√] Android Studio (version 3.6)
[√] IntelliJ IDEA Community Edition (version 2018.1)
[.] IntelliJ IDEA Ultimate Edition (version 2016.2)
X This install is older than the minimum recommended version of 2017.1.0.
[√] VS Code, 32-bit edition (version 1.63.2)
[√] Connected device (2 available)
. Doctor found issues in 2 categories.
I leave the answer as a reference for another person who has the same error.
await GoogleSignIn().signOut();
Implementado en un IconButton:
IconButton(
onPressed: (() async {
await FirebaseAuth.instance.signOut();
await GoogleSignIn().signOut();
}),
icon: const Icon(Icons.exit_to_app))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.