Sign in with a google account, then sign out with AuthUI.getInstance().signOut(this). If you try to sign in again using google you cannot change the google account you want to use to sign in. I think AuthUI.signOut does not call the provider's (googleApi) signOut method.
You should sign out from Google explicitly:
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(status -> {
mFirebaseAuth.signOut();
});
It'd be nice if AuthUI.getInstance().signOut() would figure out which provider the user has used to sign in, and call the right method from that provider.
@vinaybn92 this is a good feature request and I believe it's something we have on the roadmap.
@samtstern I think this is documented in FirebaseUI-Android Auth Readme in the SignOut Section Point no 3.
Text tells that you already have it on board:
3 If the current user signed in using either Google or Facebook, the user must also be signed out using the associated API for that authentication method. This typically ensures that the user will not be automatically signed-in using the current account when using that authentication method again from the authentication method picker, which would also prevent the user from switching between accounts on the same provider.
In order to make this process easier, AuthUI provides a simple signOut method to encapsulate this behavior. The method returns a Task which is marked completed once all necessary sign-out operations are completed
If the current signOut method doesn't have this, it should be removed till implemented.
Fixed implemented in #238, will make it into next release.
This fix for this issue is included in version 0.5.0.
This issue has been closed but I am still having it in 1.0.1
Iverc's snippet is nice but never once do I need to use the googleApiClient outside of signing out. I am having problems trying to do that method because not only do you have to create a GoogleApiClient object but you have to wait for it to connect... just so you can sign out of the google account.
@BinaryWaves A helper method was added in v0.5.0: AuthUI.getInstance().signOut(Activity);. I would highly recommend taking a look at the documentation which is much more up to date and accurate than github issues.
For somebody who come here for a solution, here is the code piece that worked for me signing out of Google account and the next Sign In is a fresh start.
`AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(@NonNull Task<Void> task) {
// user is now signed out
startActivity(new Intent(MainActivity.this, FirebaseUIActivity.class));
finish();
}
});`
Most helpful comment
It'd be nice if AuthUI.getInstance().signOut() would figure out which provider the user has used to sign in, and call the right method from that provider.