public async Task LogoutAsync() { var accounts = await _accountStore.FindAccountsForServiceAsync(AuthProvider); foreach (var account in accounts) { await _accountStore.DeleteAsync(account, AuthProvider); } }
public async Task DeleteAccount() { if (!await IsAccountExists()) { return; } AccountStore accountStore = AccountStore.Create(); var accountsSearch = await accountStore .FindAccountsForServiceAsync(App.AppName); var oldAccount = accountsSearch.FirstOrDefault(); await accountStore.DeleteAsync(oldAccount, App.AppName); }
public async Task LogoutAsync() { _settingsService.UserName = string.Empty; var accounts = await _accountStore.FindAccountsForServiceAsync(AuthProvider); foreach (var account in accounts) { await _accountStore.DeleteAsync(account, AuthProvider); } _authenticator.Logout(); }
async void OnFacebookAuthCompleted(object sender, AuthenticatorCompletedEventArgs e) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= OnAuthCompleted; authenticator.Error -= OnAuthError; } if (e.IsAuthenticated) { var tokeType = e.Account.Properties.ContainsKey("token_type") ? e.Account.Properties["token_type"] : ""; var accessToken = e.Account.Properties.ContainsKey("access_token") ? e.Account.Properties["access_token"] : ""; var expires = e.Account.Properties.ContainsKey("expires_in") ? e.Account.Properties["expires_in"] : ""; Debug.WriteLine($"{tokeType} Access Token : {accessToken}"); var request = new OAuth2Request("GET", new Uri(Constants.FacebookUserProfileUrl), null, e.Account); await request.GetResponseAsync().ContinueWith(t => { if (t.IsFaulted) { Console.WriteLine("Error: " + t.Exception.InnerException.Message); } else { string json = t.Result.GetResponseText(); Console.WriteLine(json); } }); if (_account != null) { await _store.DeleteAsync(_account, Constants.AppName); } //Can only save on the physical phone to the keychain, otherwise an exception is known, bug on iOS simulator //await _store.SaveAsync(_account = e.Account, Constants.AppName); } }
private async Task Logout(bool internalAppLogoutOnly) { Account account = GetAccount(); if (account != null) { await _accountStore.DeleteAsync(account, _configProvider.AppName); } if (internalAppLogoutOnly == false) { WebAuthenticator.ClearCookies(); // This won't work due security reasons >> We need to store id_token + calling InvokeLogout?id_token=... } }
public virtual async Task Logout(object state = null, string client_id = null, CancellationToken cancellationToken = default(CancellationToken)) { Account account = GetAccount(); if (account != null) { await _accountStore.DeleteAsync(account, _clientAppProfile.AppName).ConfigureAwait(false); Token token = account; if (!string.IsNullOrEmpty(token.id_token)) { CurrentAction = "Logout"; CurrentLogoutTaskCompletionSource = new TaskCompletionSource <object>(); _browserService.OpenUrl(GetLogoutUrl(token.id_token, state, client_id)); await CurrentLogoutTaskCompletionSource.Task; } } }