Beispiel #1
0
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            AccessTokenDisplay.Clear();
            OtherDataDisplay.Clear();

            var result = await _oidcClient.LoginAsync(DisplayMode.Visible);

            if (result.IsError)
            {
                MessageBox.Show(this, result.Error, "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                AccessTokenDisplay.Text = result.AccessToken;

                var sb = new StringBuilder(128);
                foreach (var claim in result.User.Claims)
                {
                    sb.AppendLine($"{claim.Type}: {claim.Value}");
                }

                if (!string.IsNullOrWhiteSpace(result.RefreshToken))
                {
                    sb.AppendLine($"refresh token: {result.RefreshToken}");
                }

                OtherDataDisplay.Text = sb.ToString();

                _apiClient             = new HttpClient(result.RefreshTokenHandler);
                _apiClient.BaseAddress = new Uri("https://api.identityserver.io/");
            }
        }
Beispiel #2
0
        private async void LogoutButton_Click(object sender, EventArgs e)
        {
            await _oidcClient.LogoutAsync(trySilent : Silent.Checked);

            AccessTokenDisplay.Clear();
            OtherDataDisplay.Clear();
        }