private async void _login_Done(object sender, AuthorizeResponse e)
 {
     _result = await ValidateResponseAsync(e);
     ShowTokenResult();
 }
        private async void refresh_Click(object sender, RoutedEventArgs e)
        {
            if (_config == null)
            {
                await LoadOpenIdConnectConfigurationAsync();
            }

            var tokenClient = new TokenClient(
                _config.TokenEndpoint,
                _settings.ClientId,
                _settings.ClientSecret);

            _provider = JwkNetExtensions.CreateProvider();

            var jwk = _provider.ToJsonWebKey();

            var tokenResponse = await tokenClient.RequestRefreshTokenPopAsync(
                refreshToken: _result?.RefreshToken,
                algorithm: jwk.Alg,
                key: jwk.ToJwkString());

            if (tokenResponse.IsError)
            {
                _result = new LoginResult { ErrorMessage = tokenResponse.Error };
            }
            else
            {
                _result = new LoginResult
                {
                    Success = true,
                    AccessToken = tokenResponse.AccessToken,
                    RefreshToken = tokenResponse.RefreshToken,
                    IdentityToken = tokenResponse.IdentityToken,
                    AccessTokenExpiration = DateTime.Now.AddSeconds(tokenResponse.ExpiresIn)
                };
            }

            ShowTokenResult();
        }