Search code examples
androidkotlingoogle-signingoogle-identitygoogle-one-tap

Which method to use SignInClient#signOut() or GoogleSignInClient#signOut()?


I'm trying to implement One Tap sign-in with Google. Now when I need to sign out my a user the docs say that:

When a user signs out of your app, call the One Tap client's signOut() method.

So we have to call SignInClient#signOut() method. On the other hand, because I want to sign in with Google, I found another method called GoogleSignInClient#signOut(). I'm very confused about which method I should call to have a correct sign-out.


Solution

  • I also felt confused when working on Google Sign-In.

    You should use SignInClient.signOut() method in One Tap sign-out. This signs the user out of your app's One Tap session, meaning they won't be automatically recognized for One Tap sign-in anymore.

    And use the GoogleSignInClient.signOut() method in Google Account sign-out. This signs the user out of their Google Account across your app and other apps that use Google sign-in.


    Now, If you only want to sign the user out of One Tap, use SignInClient.signOut(), this keeps their Google Account signed in for other features in your app that might need it.
    And if you want to sign the user out of their entire Google Account across your app, use GoogleSignInClient.signOut(), this includes One Tap functionality.


    [Note : You can call both methods together if you want to sign the user out of everything (One Tap and Google Account). Remember, SignInClient manages One Tap sessions, while GoogleSignInClient manages Google Account connections.]


    Hopefully, this clarifies the difference and helps you choose the correct sign-out method for your scenario!