diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-06 06:53:13 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-06 06:53:13 -0700 |
commit | 9de088f6b539f6d205c01ed405307d59b17fe4f0 (patch) | |
tree | 4f64638c49ddbebbf7d9dc04acf1aded3de37a0f /samples/OAuthConsumerWpf | |
parent | 52a3f817009b1ea7294767b4c045030e138ce170 (diff) | |
download | DotNetOpenAuth-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')
-rw-r--r-- | samples/OAuthConsumerWpf/Authorize2.xaml.cs | 22 | ||||
-rw-r--r-- | samples/OAuthConsumerWpf/MainWindow.xaml | 6 | ||||
-rw-r--r-- | samples/OAuthConsumerWpf/MainWindow.xaml.cs | 4 |
3 files changed, 21 insertions, 11 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 diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml b/samples/OAuthConsumerWpf/MainWindow.xaml index 05370d7..4488fab 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml +++ b/samples/OAuthConsumerWpf/MainWindow.xaml @@ -152,7 +152,7 @@ <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> <Label Grid.Row="1">Token Endpoint URL</Label> - <TextBox Grid.Row="1" Grid.Column="1" x:Name="wrapTokenUrlBox" /> + <TextBox Grid.Row="1" Grid.Column="1" x:Name="wrapTokenUrlBox" Text="https://graph.facebook.com/oauth/access_token" /> <Label Grid.Row="1" Grid.Column="2">POST</Label> <Label Grid.Row="2">User Authorization URL</Label> <TextBox Grid.Row="2" Grid.Column="1" x:Name="wrapAuthorizationUrlBox" Text="https://graph.facebook.com/oauth/authorize?display=popup" /> @@ -180,11 +180,11 @@ <Label Grid.Row="4">Client Identifier</Label> <TextBox Grid.Row="4" Grid.Column="1" x:Name="wrapClientIdentifierBox" Grid.ColumnSpan="2" Text="367207604173" /> <Label Grid.Row="5">Client Secret</Label> - <TextBox Grid.Row="5" Grid.Column="1" x:Name="wrapClientSecretBox" Grid.ColumnSpan="2"/> + <TextBox Grid.Row="5" Grid.Column="1" x:Name="wrapClientSecretBox" Grid.ColumnSpan="2" Text="1df77e64055c4d7d3583cefdf2bc62d7"/> <Label Grid.Row="6">OAuth 2.0 version</Label> <ComboBox Grid.Row="6" Grid.Column="1" SelectedIndex="0" x:Name="wrapVersion"> <ComboBox.Items> - <ComboBoxItem>2.0 DRAFT 5</ComboBoxItem> + <ComboBoxItem>2.0 DRAFT 9</ComboBoxItem> </ComboBox.Items> </ComboBox> <Button Grid.Row="7" Grid.Column="1" x:Name="wrapBeginButton" Click="wrapBeginButton_Click">Begin</Button> diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml.cs b/samples/OAuthConsumerWpf/MainWindow.xaml.cs index f315922..b7da074 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml.cs +++ b/samples/OAuthConsumerWpf/MainWindow.xaml.cs @@ -212,9 +212,7 @@ try { ////var client = new DotNetOpenAuth.OAuth2.WebAppClient(authServer); ////client.PrepareRequestUserAuthorization(); - var client = new OAuth2.UserAgentClient(authServer) { - ClientIdentifier = wrapClientIdentifierBox.Text, - }; + var client = new OAuth2.UserAgentClient(authServer, wrapClientIdentifierBox.Text, wrapClientSecretBox.Text); var authorizePopup = new Authorize2(client); authorizePopup.Owner = this; |