Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to logout of Google Sign-In?

How do I logout out of Google Sign In?

I know that I would be able to call mGoogleSignInClient.signOut(), but I create the mGoogleSignInClient in my login activity. How could I access it in my settings activity (where the logout happens)?

val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken("id_token")
        .requestEmail()
        .build()

googleSignInClient = GoogleSignIn.getClient(this, gso)

In my settings activity, where I have the logout button, I want to be able to call some static method relating to the Google Sign-In SDK and logout.

Do I really need to repeat the steps above (which I implemented in my login activity) into my settings activity (where the logout button is)?

like image 263
rgoncalv Avatar asked Dec 19 '22 01:12

rgoncalv


1 Answers

You can use this for logout click

Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
   @Override
   public void onResult(@NonNull Status status) {
      //set your action after log out
   }
});
like image 121
arjun shrestha Avatar answered Jan 09 '23 01:01

arjun shrestha