Sign out of a google Account in xamarin

Asgar Ali 86 Reputation points
2022-07-12T18:42:38.92+00:00

in my application on android platform user can sign in with google.
but i cant figure how to sign out of google account.
i tried the following but that does not appears to work.

  FirebaseAuth.GetInstance(MainActivity.app).SignOut();  
  FirebaseAuth.Instance.SignOut();  
  
Developer technologies | .NET | Xamarin
{count} votes

1 answer

Sort by: Most helpful
  1. Asgar Ali 86 Reputation points
    2022-07-13T18:17:29.94+00:00

    Thanks a lot finally i can signout of a google account .still there is some minor error(exceptions).

    Here is the code for signing out.

    [Obsolete]  
            public async Task<bool> Logout()  
            {  
                try  
                {  
                    FirebaseAuth.Instance.SignOut();  
                    await Android.Gms.Auth.Api.Auth.GoogleSignInApi.SignOut(GoogleLoginActivity.mGoogleApiClient);  
                    return true;  
                }  
                catch (Exception ex)  
                {  
                    await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");  
                    return false;  
                }  
            }  
    

    signout code without Obselete attribute

      public async Task<bool> Logout()  
            {  
                try  
                {  
                    FirebaseAuth.Instance.SignOut();  
                    await MainActivity.mGoogleSignInClient.SignOutAsync();  
                    return true;  
                }  
                catch (Exception ex)  
                {  
                    await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");  
                    return false;  
                }  
            }  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.