skip to Main Content

How to logout a user so that the next login lets him chose an account? It’s like there is still some metadata stored somewhere because it always relogs into the last successfully logged in account.

I found the exact problem described in this thread but for JavaScript: Firebase logout not working

How can I implement the solution:

var provider = new firebase.auth.GoogleAuthProvider(); 
provider.setCustomParameters({ prompt: 'select_account' });

in Java? Because as far as I understood, the JavaScript API is different from Java and I cannot directly create a GoogleAuthProvider() object.

2

Answers


  1. if you are using firebase Authentication in your web app then you also need to give the user account delete option as per the user’s need. We can simply do it in firebase by just simply calling the firebase delete method
    hope this helps

    Login or Signup to reply.
  2. In Java, you can’t directly set custom parameters like in JavaScript. However, you can achieve the same effect by using the GoogleSignInOptions and GoogleSignInClient classes provided by the Google Sign-In library. Here’s how you can do it:

    // Configure sign-in to request the user's ID, email address, and basic profile.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    
    // Build a GoogleSignInClient with the options specified by gso.
    GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
    
    // Then, when you want to sign out:
    mGoogleSignInClient.signOut()
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    // Update UI
                }
            });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search