How to logout google authentication?

前端 未结 1 1045
逝去的感伤
逝去的感伤 2021-01-25 16:45

I have integrated Google authenticate login in my app but after once login if I log out my account still every time app automatically sign in the old user account.

Main

相关标签:
1条回答
  • 2021-01-25 17:38

    You also need to sign out from GoogleSignInClient and FirebaseAuth current user, something like this:

     //sign out of the user and start login activity.
    public void signOut() {
        signOutBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestEmail()
                        .build();
               GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(getContext(), gso);
               mGoogleSignInClient.signOut();
               FirebaseAuth.getInstance().signOut();
               startActivity(new Intent(getContext(), LoginActivity.class));
            }
        });
    }
    
    0 讨论(0)
提交回复
热议问题