private async Task <bool> RefreshToken(IMobileServiceClient client) { try { await client.RefreshUserAsync(); return(true); } catch (System.Exception e) { Debug.WriteLine("Unable to refresh user: " + e); } return(false); }
private async Task <bool> RefreshToken(IMobileServiceClient client) { try { await client.RefreshUserAsync(); return(true); } catch (System.Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "AuthHandler", "Unable to refresh user" } }); } return(false); }
/// <summary> /// Refreshes access token with the identity provider for the logged in user. /// </summary> /// <returns>An authenticated Azure user</returns> public async Task <MobileServiceUser> RefreshUserAsync() { if (_client.CurrentUser == null && !EnsureLoggedIn(false)) { return(null); } var user = await _client.RefreshUserAsync(); IAptkAmaCredentials credentials; if (_configuration.CacheService != null && _configuration.CacheService.TryLoadCredentials(out credentials)) { _configuration.CacheService.SaveCredentials(new AptkAmaCredentials(credentials.Provider, user)); } return(user); }
public async Task <MobileServiceUser> LoginAsync(MobileServiceAuthenticationProvider provider) { if (CheckForUser()) { try { var refreshed = await _client.RefreshUserAsync(); if (refreshed != null) { StoreTokenInSecureStore(refreshed); return(refreshed); } } catch (Exception refreshException) { Debug.WriteLine($"Could not refresh token: {refreshException.Message}"); } if (!IsTokenExpired(_client.CurrentUser.MobileServiceAuthenticationToken)) { return(_client.CurrentUser); } } try { await _loginHelper.LoginAsync(provider, _client); } catch (Exception e) when(e.GetType() == typeof(InvalidOperationException) || e.Message.Contains("canceled by the user")) { return(null); } if (_client.CurrentUser != null) { // We were able to successfully log in StoreTokenInSecureStore(_client.CurrentUser); } return(_client.CurrentUser); }
public virtual async Task <bool> RefreshUser(IMobileServiceClient client) { try { var user = await client.RefreshUserAsync(); if (user != null) { client.CurrentUser = user; Settings.AuthToken = user.MobileServiceAuthenticationToken; return(true); } } catch (System.Exception e) { Debug.WriteLine("Unable to refresh user: " + e); } return(false); }
public virtual async Task <bool> RefreshUser(IMobileServiceClient client) { try { var user = await client.RefreshUserAsync(); if (user != null) { client.CurrentUser = user; Settings.AuthToken = user.MobileServiceAuthenticationToken; Settings.UserId = user.UserId; return(true); } } catch (Exception ex) { Insights.Report(ex, Insights.Severity.Error); } return(false); }
public virtual async Task<bool> RefreshUser(IMobileServiceClient client) { try { var user = await client.RefreshUserAsync(); if (user != null) { client.CurrentUser = user; Settings.AuthToken = user.MobileServiceAuthenticationToken; Settings.UserId = user.UserId; return true; } } catch (System.Exception e) { Debug.WriteLine("Unable to refresh user: " + e); } return false; }