diff options
Diffstat (limited to 'samples/OAuthConsumerWpf/Authorize2.xaml.cs')
-rw-r--r-- | samples/OAuthConsumerWpf/Authorize2.xaml.cs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/samples/OAuthConsumerWpf/Authorize2.xaml.cs b/samples/OAuthConsumerWpf/Authorize2.xaml.cs index 4a0a969..9c5c2dc 100644 --- a/samples/OAuthConsumerWpf/Authorize2.xaml.cs +++ b/samples/OAuthConsumerWpf/Authorize2.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using DotNetOpenAuth.OAuth2; + using DotNetOpenAuth.Messaging; /// <summary> /// Interaction logic for Authorize2.xaml @@ -38,10 +39,15 @@ } private void locationChanged(Uri location) { - if (location == this.Authorization.Callback) { - this.client.ProcessUserAuthorization(location, this.Authorization); - this.DialogResult = !string.IsNullOrEmpty(this.Authorization.AccessToken); - this.Close(); + if (SignificantlyEqual(location, this.Authorization.Callback, UriComponents.SchemeAndServer | UriComponents.Path)) { + try { + this.client.ProcessUserAuthorization(location, this.Authorization); + } catch (ProtocolException ex) { + MessageBox.Show(ex.ToStringDescriptive()); + } finally { + this.DialogResult = !string.IsNullOrEmpty(this.Authorization.AccessToken); + this.Close(); + } } } @@ -52,5 +58,11 @@ private void webBrowser_LocationChanged(object sender, EventArgs e) { this.locationChanged(webBrowser.Url); } + + private static bool SignificantlyEqual(Uri location1, Uri location2, UriComponents components) { + string value1 = location1.GetComponents(components, UriFormat.Unescaped); + string value2 = location2.GetComponents(components, UriFormat.Unescaped); + return string.Equals(value1, value2, StringComparison.Ordinal); + } } -} +}
\ No newline at end of file |