I'm using https://www.pujolsluis.com/google-client-plugin-for-xamarin/ for google sign in xamarin forms. Both Login and Logout methods work fine; but i have to hide the login page after successful login.After opening the app from second time onwards, logout method throws java.Lang.IlegalStateException<Timeout exceeded getting exception details>
,cannot logout.Active token is null.How to handle this exception? How to logout successfully from second time?
Login:
public IGoogleClientManager googleClientManager;
googleClientManager = CrossGoogleClient.Current;
private void google_btn_Clicked(object sender, EventArgs e)
{
if (CrossConnectivity.Current.IsConnected)
{
googleClientManager.LoginAsync();
googleClientManager.OnLogin += OnLoginCompleted;
// CrossGoogleClient.Current.SilentLoginAsync();
// var userToken = CrossGoogleClient.Current.ActiveToken;
}
else
{
DependencyService.Get<IToast>().LongAlert("Check Connection!");
}
}
public async void OnLoginCompleted(object s,
GoogleClientResultEventArgs<GoogleUser> loginEventArgs)
{
if (loginEventArgs.Data != null)
{
GoogleUser googleUser = loginEventArgs.Data;
string google_name = googleUser.Name;
string google_mail = googleUser.Email;
Uri google_img = googleUser.Picture;
googleClientManager.OnLogin -= OnLoginCompleted;
}
}
Logout:
public void Logout()
{
googleClientManager.OnLogout += OnLogoutCompleted;
googleClientManager.Logout(); // throws exception from secondtime after hiding loginpage
}
private void OnLogoutCompleted(object sender, EventArgs loginEventArgs)
{
googleClientManager.OnLogout -= OnLogoutCompleted;
}