Home > Blockchain >  Firebase Google auth, signing out and logging in again will log in with the last signed account
Firebase Google auth, signing out and logging in again will log in with the last signed account

Time:11-26

I am using Firebase Google Auth, signing out and logging in again will log in with the last signed account. How can I make it show the "choose account" dialog? this is what I did to log out. FirebaseAuth.getInstance().signOut(); and then I call sign-in activity. Also, the logout button is in a different activity.

CodePudding user response:

this is what I did to log out.

FirebaseAuth.getInstance().signOut();

When you try to sign out using the above line of code, it basically means that you are signing out only from Firebase.

I am using Firebase Google Auth, signing out and logging in again will log in with the last signed account. How can I make it show the "choose account" dialog?

As I see, you are using Google authentication. Signing out from Firebase doesn't mean that you are automatically signed out from Google. It doesn't. To sign out from Google you have to explicitly add a call to GoogleSignInClient#signOut() method, like this:

googleSignInClient.signOut();

Please don't forget that the sign-out operation is asynchronous, meaning that you have to wait until the operation completes, which may take some time. Since this method returns an object of type Task, you can use addOnCompleteListener(OnCompleteListener listener) method, to know when you are completely signed out.

  • Related