summaryrefslogtreecommitdiffstats
path: root/samples/OAuthConsumerWpf/Authorize2.xaml.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-07-06 06:53:13 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-07-06 06:53:13 -0700
commit9de088f6b539f6d205c01ed405307d59b17fe4f0 (patch)
tree4f64638c49ddbebbf7d9dc04acf1aded3de37a0f /samples/OAuthConsumerWpf/Authorize2.xaml.cs
parent52a3f817009b1ea7294767b4c045030e138ce170 (diff)
downloadDotNetOpenAuth-9de088f6b539f6d205c01ed405307d59b17fe4f0.zip
DotNetOpenAuth-9de088f6b539f6d205c01ed405307d59b17fe4f0.tar.gz
DotNetOpenAuth-9de088f6b539f6d205c01ed405307d59b17fe4f0.tar.bz2
Got the OAuthConsumerWpf sample working with Facebook OAuth 2.0 again.
Diffstat (limited to 'samples/OAuthConsumerWpf/Authorize2.xaml.cs')
-rw-r--r--samples/OAuthConsumerWpf/Authorize2.xaml.cs22
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