public async Task <bool> LogoutAsync() { try { await _client.LogoutAsync(new LogoutRequest() { BrowserDisplayMode = DisplayMode.Hidden, IdTokenHint = _result.IdentityToken }); Debug.Log("UnityAuthClient::Signed out successfully."); return(true); } catch (Exception e) { Debug.Log("UnityAuthClient::Failed to sign out: " + e.Message); } finally { Debug.Log("UnityAuthClient::Dismissing sign-out browser."); Browser.Dismiss(); _client = null; } return(false); }
private async void LogoutWabButton_Click(object sender, RoutedEventArgs e) { var options = new OidcClientOptions { Authority = "https://demo.identityserver.io", ClientId = "native.hybrid", Scope = "openid profile api offline_access", RedirectUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri, PostLogoutRedirectUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri, ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect, Browser = new WabBrowser(enableWindowsAuthentication: false) }; var client = new OidcClient(options); try { await client.LogoutAsync(new LogoutRequest() { BrowserDisplayMode = DisplayMode.Hidden, IdTokenHint = _result.IdentityToken }); } catch (Exception ex) { // TODO: This is never called: See https://github.com/IdentityModel/IdentityModel.OidcClient2/issues/123 } }
private async void LogoutButton_Click(object sender, EventArgs e) { await _oidcClient.LogoutAsync(trySilent : Silent.Checked); AccessTokenDisplay.Clear(); OtherDataDisplay.Clear(); }
public async Task <LogoutResult> Logout(string?identityToken) { OidcClient oidcClient = CreateOidcClient(); LogoutResult logoutResult = await oidcClient.LogoutAsync(new LogoutRequest { IdTokenHint = identityToken }); return(logoutResult); }
public async Task SignOutAsync() { var client = new OidcClient(GetIdentityOptions()); await client.LogoutAsync(); ResetInfo(); }
public async Task <bool> LogoutAsync() { var callbackUri = this.appSettingsManager["Authorization:LogoutCallback"]; var options = new OidcClientOptions { Authority = $"https://{this.domain}", ClientId = this.clientId, Scope = "openid profile email", RedirectUri = callbackUri, ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect, Flow = OidcClientOptions.AuthenticationFlow.AuthorizationCode, Browser = new Browser() }; var oidcClient = new OidcClient(options); var result = await oidcClient.LogoutAsync(new LogoutRequest()); if (result.IsError) { throw new AuthenticationException(result.Error); } return(true); }
public async Task <LogoutResult> Logout() { // OidcClient oidcClient = CreateOidcClient("oidcxamarin101:/signout-callback-oidc"); OidcClient oidcClient = CreateOidcClient(); LogoutResult logoutResult = await oidcClient.LogoutAsync(new LogoutRequest()); return(logoutResult); }
public async Task <LogoutResult> Logout() { if (_client == null || _loginResult == null || !_loginResult.User.Identity.IsAuthenticated) { return(null); } var logoutResult = await _client.LogoutAsync(new LogoutRequest { IdTokenHint = _loginResult.IdentityToken }); return(logoutResult); }
// logout is currently not support by SFAuthenticationSession // https://forums.developer.apple.com/thread/91647 private async void LogoutButton_TouchUpInside(object sender, EventArgs e) { OutputText.Text = ""; var request = new LogoutRequest { IdTokenHint = _user.IdentityToken }; _user = null; await _client.LogoutAsync(request); }
private async void Logout_Clicked(object sender, EventArgs e) { var logoutRequest = new LogoutRequest(); _isAuthenticated = false; CallApi.IsVisible = false; Login.IsVisible = true; Logout.IsVisible = false; OutputText.Text = string.Empty; await _client.LogoutAsync(logoutRequest); }
private static async Task NextSteps(LoginResult result) { var currentAccessToken = result.AccessToken; var currentRefreshToken = result.RefreshToken; var menu = " x...exit c...call api o..logout "; if (currentRefreshToken != null) { menu += "r...refresh token "; } while (true) { Console.WriteLine("\n\n"); Console.Write(menu); var key = Console.ReadKey(); if (key.Key == ConsoleKey.X) { return; } if (key.Key == ConsoleKey.C) { await CallApi(currentAccessToken); } if (key.Key == ConsoleKey.O) { await _oidcClient.LogoutAsync(); } if (key.Key == ConsoleKey.R) { var refreshResult = await _oidcClient.RefreshTokenAsync(currentRefreshToken); if (result.IsError) { Console.WriteLine($"Error: {refreshResult.Error}"); } else { currentRefreshToken = refreshResult.RefreshToken; currentAccessToken = refreshResult.AccessToken; Console.WriteLine("\n\n"); Console.WriteLine($"access token: {result.AccessToken}"); Console.WriteLine($"refresh token: {result?.RefreshToken ?? "none"}"); } } } }
public override async Task SignOutAsync() { await _client.LogoutAsync(); await OnSignOut(); RemoveCredential(RefreshToken); IsLoggedIn = false; _client = null; _state = null; Token = RefreshToken = null; CurrentUser = null; }
public static async Task <bool> LogoutIdsAsync() { await DeRegisterDevice(); App.Database.ResetAll(); string idToken = ""; try { idToken = await SecureStorage.GetAsync(Constants.AuthIdTokenKey); } catch (Exception ex) { Debug.WriteLine(ex.Message); } try { string pnsHandle = await SecureStorage.GetAsync("PnsHandle"); SecureStorage.RemoveAll(); await SecureStorage.SetAsync("PnsHandle", pnsHandle); } catch (Exception ex) { Debug.WriteLine(ex.Message); } var browser = DependencyService.Get <IBrowser>(); var options = new OidcClientOptions { Authority = Constants.AuthServerUrl, ClientId = "kinaunaxamarin", RedirectUri = "kinaunaxamarinclients://callback", PostLogoutRedirectUri = "kinaunaxamarinclients://callback", Scope = "openid profile email firstname middlename lastname timezone viewchild kinaunaprogenyapi kinaunamediaapi", Browser = browser, ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect }; var oidcClient = new OidcClient(options); LogoutRequest logoutRequest = new LogoutRequest(); logoutRequest.IdTokenHint = idToken; await oidcClient.LogoutAsync(logoutRequest); return(true); }
private async void _logoutButton_Click(object sender, EventArgs e) { var logoutRequest = new LogoutRequest() { IdTokenHint = _identityToken }; _oidcClient = new OidcClient(_options); var logoutResult = await _oidcClient.LogoutAsync(logoutRequest); _accessToken = null; _refreshToken = null; StartActivity(GetType()); }
private async Task Logout() { SecureStorage.Remove(Constants.AccessToken); Preferences.Remove(Constants.UserID); try { await client.LogoutAsync(); } catch (Exception ex) { throw; } CanLogIn = true; IsAdmin = false; LoginStatus = "Log In"; UserName = null; }
private async void Logout_Clicked(object sender, EventArgs e) { var logoutRequest = new LogoutRequest(); await _client.LogoutAsync(logoutRequest); }
public async Task Logout() { await _client.LogoutAsync(new LogoutRequest()); _result = null; }
public async Task <string> Logout() { var _result = await _oidcClient.LogoutAsync(); return(_result.Error); }
public static async void Logout() { await _oidcClient.LogoutAsync().ConfigureAwait(false); }
private static async Task NextSteps(LoginResult result) { var currentIdToken = result.IdentityToken; var currentAccessToken = result.AccessToken; var currentRefreshToken = result.RefreshToken; var menu = " x...exit l...get levels d...query disciplines "; if (currentRefreshToken != null) { menu += "r...refresh token o...sign out "; } while (true) { Console.WriteLine("\n\n"); Console.Write(menu); var key = Console.ReadKey(); if (key.Key == ConsoleKey.X) { return; } if (key.Key == ConsoleKey.L) { await GetLevels(currentAccessToken); } if (key.Key == ConsoleKey.D) { await QueryDisciplines(currentAccessToken); } if (key.Key == ConsoleKey.R) { var refreshResult = await _oidcClient.RefreshTokenAsync(currentRefreshToken); if (refreshResult.IsError) { Console.WriteLine($"Error: {refreshResult.Error}"); } else { currentRefreshToken = refreshResult.RefreshToken; currentAccessToken = refreshResult.AccessToken; Console.WriteLine("\n\n"); Console.WriteLine($"access token: {currentAccessToken}"); Console.WriteLine($"refresh token: {currentRefreshToken ?? "none"}"); } } if (key.Key == ConsoleKey.O) { // Get the URI for the Revocation Endpoint var disco = await _apiClient.GetDiscoveryDocumentAsync(_authority); if (disco.IsError) { Console.WriteLine("Failed to access Discovery Document"); break; } // Revoke the Refresh Token var revokeResult = await _apiClient.RevokeTokenAsync(new TokenRevocationRequest { Address = disco.RevocationEndpoint, ClientId = _clientId, Token = currentRefreshToken, TokenTypeHint = "refresh_token" }); // Sign out from the ID Server await _oidcClient.LogoutAsync(new LogoutRequest { IdTokenHint = currentIdToken }); } } }