I am using Firebase Google Auth, signing out and logging in again will log in with last signed account. How can I make account chooser every time?
Asked
Active
Viewed 4,138 times
7
-
1Duplicate of http://stackoverflow.com/q/38707133/4815718 – Bob Snyder Dec 07 '16 at 13:52
2 Answers
3
This part of Firebase Authentication with just a Google Sign In Button in place has given me a lot of nightmares, and if you have encountered the same issue, then I can assure that this answer will save you tons of hours!
Wherever you are implementing the Sign Out functionality, remember to use this line of code and you are good to go.
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignIn
GoogleSignIn.getClient(this, GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).build())
.signOut()
This is a kotlin code.

Devansh Nigam
- 59
- 1
- 6
-
This is not working for me. Even after signout, i'm not getting account chooser screen. I'm using this dependency 'com.google.android.gms:play-services-auth:20.2.0'. – K Pradeep Kumar Reddy May 31 '22 at 21:38
2
Firebase Auth Quickstart sample code provides the following few steps for sign out
Declare Globally these two variables
private GoogleSignInClient mGoogleSignInClient;
private GoogleSignInOptions gso;
Add these lines in onCreate method
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
Now for signOut
private void signOut() {
// Firebase sign out
mAuth.signOut();
// Google sign out
mGoogleSignInClient.signOut().addOnCompleteListener(this,
new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
updateUI(null);
}
});
}
It's easy, and it will work. Cheers!

akhil
- 1,649
- 3
- 19
- 31
-
This is not working for me. Even after signout, i'm not getting account chooser screen. I'm using this dependency 'com.google.android.gms:play-services-auth:20.2.0'. – K Pradeep Kumar Reddy May 31 '22 at 21:38