prevent google credentials save in android

Viewed 73

I am using Firebase Google Authentication services. Authentication is working fine, But the problem is that when I sign In with google auth, credentials get saved. So after every logout, I can not be able to choose an email for login. It directly login me into the app. So it becomes a problem for me when I want to login with another Gmail account.

Code to achieve the credentials page.

google_sign_in_btn.setOnClickListener {
            signIn()
        }
  ...


private fun signIn() {
    val signInIntent = mGoogleSignInClient.signInIntent
    startActivityForResult(signInIntent, 234)
}


override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (requestCode == 234)
        {
            val task = GoogleSignIn.getSignedInAccountFromIntent(data)
            try
            {
                val account = task.getResult(ApiException::class.java)
                if (account != null) {
                    firebaseAuthWithGoogle(account)
                }
            }
            catch (e:ApiException) {
            }
        }
    }
1 Answers

The problem that you are facing is that you don't sign out the user from the Google provider. It's not enough to sign out only from Firebase. If you want to get that pop-up every time, so you can choose the email account you want to use, sign out from both Google and Firebase:

googleSignInClient.signOut().addOnCompleteListener { /* ... /* }
FirebaseAuth.getInstance().signOut()
Related