Obtain the authorization code

After the user finishes the interaction with the authorization server, the user is navigated to the RedirectUri.

The user can inspect every redirect request handling the navigating event on the WebBrowser, for example:

private void webView_Navigating(object sender, NavigatingCancelEventArgs e)
{
if (e.Uri.ToString().StartsWith(_callbackUri.AbsoluteUri))
{
AuthorizeResponse = new AuthorizeResponse(e.Uri.AbsoluteUri);
e.Cancel = true;
this.Visibility = System.Windows.Visibility.Hidden;
if (Done != null)
{
Done.Invoke(this, AuthorizeResponse);
}
}
if (e.Uri.ToString().Equals("javascript:void(0)"))
{
e.Cancel = true;
}
} 
Note: There is a special case for javascript:void(0). While testing, it was detected that such navigation makes the browser unresponsive. Be aware that this functionality works when using WPF WebView as in the sample provided. Using the Winforms browser may not provide all the events as expected. In this scenario, the Thinktecture library was leveraged to parse the response URL: AuthorizeResponse = new AuthorizeResponse(e.Uri.AbsoluteUri); the AuthorizeResponse includes an error if there is a problem while obtaining the authorization code.