diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.Designer.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.Designer.cs
index 697fefbe..4f50811a 100644
--- a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.Designer.cs
+++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.Designer.cs
@@ -1,73 +1,72 @@
-namespace OpenIddict.Sandbox.WinForms.Client
+namespace OpenIddict.Sandbox.WinForms.Client;
+
+partial class MainForm
{
- partial class MainForm
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
{
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
+ components.Dispose();
}
+ base.Dispose(disposing);
+ }
- #region Windows Form Designer generated code
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.LocalLogin = new System.Windows.Forms.Button();
- this.GitHubLogin = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // LocalLogin
- //
- this.LocalLogin.Location = new System.Drawing.Point(258, 93);
- this.LocalLogin.Name = "LocalLogin";
- this.LocalLogin.Size = new System.Drawing.Size(283, 83);
- this.LocalLogin.TabIndex = 0;
- this.LocalLogin.Text = "Log in using the local server";
- this.LocalLogin.UseVisualStyleBackColor = true;
- this.LocalLogin.Click += new System.EventHandler(this.LocalLoginButton_Click);
- //
- // GitHubLogin
- //
- this.GitHubLogin.Location = new System.Drawing.Point(258, 258);
- this.GitHubLogin.Name = "GitHubLogin";
- this.GitHubLogin.Size = new System.Drawing.Size(283, 83);
- this.GitHubLogin.TabIndex = 1;
- this.GitHubLogin.Text = "Log in using GitHub";
- this.GitHubLogin.UseVisualStyleBackColor = true;
- this.GitHubLogin.Click += new System.EventHandler(this.GitHubLoginButton_Click);
- //
- // MainForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.GitHubLogin);
- this.Controls.Add(this.LocalLogin);
- this.Name = "MainForm";
- this.Text = "OpenIddict WinForms client";
- this.ResumeLayout(false);
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.LocalLogin = new System.Windows.Forms.Button();
+ this.GitHubLogin = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // LocalLogin
+ //
+ this.LocalLogin.Location = new System.Drawing.Point(258, 93);
+ this.LocalLogin.Name = "LocalLogin";
+ this.LocalLogin.Size = new System.Drawing.Size(283, 83);
+ this.LocalLogin.TabIndex = 0;
+ this.LocalLogin.Text = "Log in using the local server";
+ this.LocalLogin.UseVisualStyleBackColor = true;
+ this.LocalLogin.Click += new System.EventHandler(this.LocalLoginButton_Click);
+ //
+ // GitHubLogin
+ //
+ this.GitHubLogin.Location = new System.Drawing.Point(258, 258);
+ this.GitHubLogin.Name = "GitHubLogin";
+ this.GitHubLogin.Size = new System.Drawing.Size(283, 83);
+ this.GitHubLogin.TabIndex = 1;
+ this.GitHubLogin.Text = "Log in using GitHub";
+ this.GitHubLogin.UseVisualStyleBackColor = true;
+ this.GitHubLogin.Click += new System.EventHandler(this.GitHubLoginButton_Click);
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.GitHubLogin);
+ this.Controls.Add(this.LocalLogin);
+ this.Name = "MainForm";
+ this.Text = "OpenIddict WinForms client";
+ this.ResumeLayout(false);
- }
+ }
- #endregion
+ #endregion
- private Button LocalLogin;
- private Button GitHubLogin;
- }
+ private Button LocalLogin;
+ private Button GitHubLogin;
}
\ No newline at end of file
diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs
index 8a8b2c3e..e7d32678 100644
--- a/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs
+++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/MainForm.cs
@@ -4,97 +4,96 @@ using static OpenIddict.Abstractions.OpenIddictConstants;
using static OpenIddict.Abstractions.OpenIddictExceptions;
using static OpenIddict.Client.WebIntegration.OpenIddictClientWebIntegrationConstants;
-namespace OpenIddict.Sandbox.WinForms.Client
+namespace OpenIddict.Sandbox.WinForms.Client;
+
+public partial class MainForm : Form, IWinFormsShell
{
- public partial class MainForm : Form, IWinFormsShell
+ private readonly OpenIddictClientService _service;
+
+ public MainForm(OpenIddictClientService service)
{
- private readonly OpenIddictClientService _service;
+ _service = service ?? throw new ArgumentNullException(nameof(service));
- public MainForm(OpenIddictClientService service)
- {
- _service = service ?? throw new ArgumentNullException(nameof(service));
+ InitializeComponent();
+ }
- InitializeComponent();
- }
+ private async void LocalLoginButton_Click(object sender, EventArgs e)
+ => await AuthenticateAsync("Local");
- private async void LocalLoginButton_Click(object sender, EventArgs e)
- => await AuthenticateAsync("Local");
+ private async void GitHubLoginButton_Click(object sender, EventArgs e)
+ => await AuthenticateAsync(Providers.GitHub);
- private async void GitHubLoginButton_Click(object sender, EventArgs e)
- => await AuthenticateAsync(Providers.GitHub);
+ private async Task AuthenticateAsync(string provider)
+ {
+ using var source = new CancellationTokenSource(delay: TimeSpan.FromSeconds(90));
- private async Task AuthenticateAsync(string provider)
+ try
{
- using var source = new CancellationTokenSource(delay: TimeSpan.FromSeconds(90));
-
- try
- {
- // Ask OpenIddict to initiate the authentication flow (typically, by
- // starting the system browser) and wait for the user to complete it.
- var (_, _, principal) = await _service.AuthenticateInteractivelyAsync(
- provider, cancellationToken: source.Token);
+ // Ask OpenIddict to initiate the authentication flow (typically, by
+ // starting the system browser) and wait for the user to complete it.
+ var (_, _, principal) = await _service.AuthenticateInteractivelyAsync(
+ provider, cancellationToken: source.Token);
#if SUPPORTS_WINFORMS_TASK_DIALOG
- TaskDialog.ShowDialog(new TaskDialogPage
- {
- Caption = "Authentication successful",
- Heading = "Authentication successful",
- Icon = TaskDialogIcon.ShieldSuccessGreenBar,
- Text = $"Welcome, {principal.FindFirst(Claims.Name)!.Value}."
- });
+ TaskDialog.ShowDialog(new TaskDialogPage
+ {
+ Caption = "Authentication successful",
+ Heading = "Authentication successful",
+ Icon = TaskDialogIcon.ShieldSuccessGreenBar,
+ Text = $"Welcome, {principal.FindFirst(Claims.Name)!.Value}."
+ });
#else
- MessageBox.Show($"Welcome, {principal.FindFirst(Claims.Name)!.Value}.",
- "Authentication successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ MessageBox.Show($"Welcome, {principal.FindFirst(Claims.Name)!.Value}.",
+ "Authentication successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
#endif
- }
+ }
- catch (OperationCanceledException)
- {
+ catch (OperationCanceledException)
+ {
#if SUPPORTS_WINFORMS_TASK_DIALOG
- TaskDialog.ShowDialog(new TaskDialogPage
- {
- Caption = "Authentication timed out",
- Heading = "Authentication timed out",
- Icon = TaskDialogIcon.Warning,
- Text = "The authentication process was aborted."
- });
+ TaskDialog.ShowDialog(new TaskDialogPage
+ {
+ Caption = "Authentication timed out",
+ Heading = "Authentication timed out",
+ Icon = TaskDialogIcon.Warning,
+ Text = "The authentication process was aborted."
+ });
#else
- MessageBox.Show("The authentication process was aborted.",
- "Authentication timed out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBox.Show("The authentication process was aborted.",
+ "Authentication timed out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
#endif
- }
+ }
- catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied)
- {
+ catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied)
+ {
#if SUPPORTS_WINFORMS_TASK_DIALOG
- TaskDialog.ShowDialog(new TaskDialogPage
- {
- Caption = "Authorization denied",
- Heading = "Authorization denied",
- Icon = TaskDialogIcon.Warning,
- Text = "The authorization was denied by the end user."
- });
+ TaskDialog.ShowDialog(new TaskDialogPage
+ {
+ Caption = "Authorization denied",
+ Heading = "Authorization denied",
+ Icon = TaskDialogIcon.Warning,
+ Text = "The authorization was denied by the end user."
+ });
#else
- MessageBox.Show("The authorization was denied by the end user.",
- "Authorization denied", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBox.Show("The authorization was denied by the end user.",
+ "Authorization denied", MessageBoxButtons.OK, MessageBoxIcon.Warning);
#endif
- }
+ }
- catch
- {
+ catch
+ {
#if SUPPORTS_WINFORMS_TASK_DIALOG
- TaskDialog.ShowDialog(new TaskDialogPage
- {
- Caption = "Authentication failed",
- Heading = "Authentication failed",
- Icon = TaskDialogIcon.Error,
- Text = "An error occurred while trying to authenticate the user."
- });
+ TaskDialog.ShowDialog(new TaskDialogPage
+ {
+ Caption = "Authentication failed",
+ Heading = "Authentication failed",
+ Icon = TaskDialogIcon.Error,
+ Text = "An error occurred while trying to authenticate the user."
+ });
#else
- MessageBox.Show("An error occurred while trying to authenticate the user.",
- "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("An error occurred while trying to authenticate the user.",
+ "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
- }
}
}
}
\ No newline at end of file
diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj b/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj
index 2607d21f..0128865c 100644
--- a/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj
+++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/OpenIddict.Sandbox.WinForms.Client.csproj
@@ -24,8 +24,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/App.xaml.cs b/sandbox/OpenIddict.Sandbox.Wpf.Client/App.xaml.cs
index 57f4f898..3cad4bb0 100644
--- a/sandbox/OpenIddict.Sandbox.Wpf.Client/App.xaml.cs
+++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/App.xaml.cs
@@ -1,8 +1,7 @@
using System.Windows;
-namespace OpenIddict.Sandbox.Wpf.Client
+namespace OpenIddict.Sandbox.Wpf.Client;
+
+public partial class App : Application
{
- public partial class App : Application
- {
- }
}
diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/MainWindow.xaml.cs b/sandbox/OpenIddict.Sandbox.Wpf.Client/MainWindow.xaml.cs
index 786887a3..4f7318d8 100644
--- a/sandbox/OpenIddict.Sandbox.Wpf.Client/MainWindow.xaml.cs
+++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/MainWindow.xaml.cs
@@ -5,57 +5,56 @@ using static OpenIddict.Abstractions.OpenIddictConstants;
using static OpenIddict.Abstractions.OpenIddictExceptions;
using static OpenIddict.Client.WebIntegration.OpenIddictClientWebIntegrationConstants;
-namespace OpenIddict.Sandbox.Wpf.Client
+namespace OpenIddict.Sandbox.Wpf.Client;
+
+public partial class MainWindow : Window, IWpfShell
{
- public partial class MainWindow : Window, IWpfShell
+ private readonly OpenIddictClientService _service;
+
+ public MainWindow(OpenIddictClientService service)
+ {
+ _service = service ?? throw new ArgumentNullException(nameof(service));
+
+ InitializeComponent();
+ }
+
+ private async void LocalLoginButton_Click(object sender, RoutedEventArgs e)
+ => await AuthenticateAsync("Local");
+
+ private async void GitHubLoginButton_Click(object sender, RoutedEventArgs e)
+ => await AuthenticateAsync(Providers.GitHub);
+
+ private async Task AuthenticateAsync(string provider)
{
- private readonly OpenIddictClientService _service;
+ using var source = new CancellationTokenSource(delay: TimeSpan.FromSeconds(90));
- public MainWindow(OpenIddictClientService service)
+ try
{
- _service = service ?? throw new ArgumentNullException(nameof(service));
+ // Ask OpenIddict to initiate the authentication flow (typically, by
+ // starting the system browser) and wait for the user to complete it.
+ var (_, _, principal) = await _service.AuthenticateInteractivelyAsync(
+ provider, cancellationToken: source.Token);
- InitializeComponent();
+ MessageBox.Show($"Welcome, {principal.FindFirst(Claims.Name)!.Value}.",
+ "Authentication successful", MessageBoxButton.OK, MessageBoxImage.Information);
}
- private async void LocalLoginButton_Click(object sender, RoutedEventArgs e)
- => await AuthenticateAsync("Local");
+ catch (OperationCanceledException)
+ {
+ MessageBox.Show("The authentication process was aborted.",
+ "Authentication timed out", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
- private async void GitHubLoginButton_Click(object sender, RoutedEventArgs e)
- => await AuthenticateAsync(Providers.GitHub);
+ catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied)
+ {
+ MessageBox.Show("The authorization was denied by the end user.",
+ "Authorization denied", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
- private async Task AuthenticateAsync(string provider)
+ catch
{
- using var source = new CancellationTokenSource(delay: TimeSpan.FromSeconds(90));
-
- try
- {
- // Ask OpenIddict to initiate the authentication flow (typically, by
- // starting the system browser) and wait for the user to complete it.
- var (_, _, principal) = await _service.AuthenticateInteractivelyAsync(
- provider, cancellationToken: source.Token);
-
- MessageBox.Show($"Welcome, {principal.FindFirst(Claims.Name)!.Value}.",
- "Authentication successful", MessageBoxButton.OK, MessageBoxImage.Information);
- }
-
- catch (OperationCanceledException)
- {
- MessageBox.Show("The authentication process was aborted.",
- "Authentication timed out", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
-
- catch (ProtocolException exception) when (exception.Error is Errors.AccessDenied)
- {
- MessageBox.Show("The authorization was denied by the end user.",
- "Authorization denied", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
-
- catch
- {
- MessageBox.Show("An error occurred while trying to authenticate the user.",
- "Authentication failed", MessageBoxButton.OK, MessageBoxImage.Error);
- }
+ MessageBox.Show("An error occurred while trying to authenticate the user.",
+ "Authentication failed", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj b/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj
index 0fe35d1c..f5e64aba 100644
--- a/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj
+++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/OpenIddict.Sandbox.Wpf.Client.csproj
@@ -25,8 +25,4 @@
-
-
-
-
diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.cs
index b8b5ae4f..0fed01d4 100644
--- a/src/OpenIddict.Client/OpenIddictClientHandlers.cs
+++ b/src/OpenIddict.Client/OpenIddictClientHandlers.cs
@@ -1221,9 +1221,8 @@ public static partial class OpenIddictClientHandlers
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006));
// Resolve the negotiated flow from the state token.
- (context.GrantType, context.ResponseType) = (
- context.StateTokenPrincipal.GetClaim(Claims.Private.GrantType),
- context.StateTokenPrincipal.GetClaim(Claims.Private.ResponseType));
+ context.GrantType = context.StateTokenPrincipal.GetClaim(Claims.Private.GrantType);
+ context.ResponseType = context.StateTokenPrincipal.GetClaim(Claims.Private.ResponseType);
switch ((context.EndpointType, context.GrantType, context.ResponseType))
{