diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-17 22:04:56 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-17 22:04:56 -0700 |
commit | 7c86d53eac655514ac0c8b7c8ede95c0af5798fb (patch) | |
tree | 390b5c5a1f695812aa61c2fdfa845e4fe0ae3590 /samples | |
parent | 3ab1adf5a949a5799f6a7fee377ae3c7e77ec69a (diff) | |
parent | 17c604a07b35bcfd3a77299777521f04063bd6ae (diff) | |
download | DotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.zip DotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.tar.gz DotNetOpenAuth-7c86d53eac655514ac0c8b7c8ede95c0af5798fb.tar.bz2 |
Merge branch 'oauth2templates' into oauth2
Diffstat (limited to 'samples')
-rw-r--r-- | samples/OAuthConsumerWpf/Authorize2.xaml.cs | 8 | ||||
-rw-r--r-- | samples/OAuthConsumerWpf/MainWindow.xaml | 41 | ||||
-rw-r--r-- | samples/OAuthConsumerWpf/MainWindow.xaml.cs | 10 |
3 files changed, 36 insertions, 23 deletions
diff --git a/samples/OAuthConsumerWpf/Authorize2.xaml.cs b/samples/OAuthConsumerWpf/Authorize2.xaml.cs index d407a51..8cf9f6f 100644 --- a/samples/OAuthConsumerWpf/Authorize2.xaml.cs +++ b/samples/OAuthConsumerWpf/Authorize2.xaml.cs @@ -22,14 +22,16 @@ public partial class Authorize2 : Window { private UserAgentClient client; - internal Authorize2(UserAgentClient client) { + internal Authorize2(UserAgentClient client, IAuthorizationState authorizationState) { Contract.Requires(client != null, "client"); + Contract.Requires(authorizationState != null, "authorizationState"); InitializeComponent(); this.client = client; - this.Authorization = new AuthorizationState(); - this.webBrowser.Navigate(this.client.RequestUserAuthorization(this.Authorization)); + this.Authorization = authorizationState; + Uri authorizationUrl = this.client.RequestUserAuthorization(this.Authorization); + this.webBrowser.Navigate(authorizationUrl.AbsoluteUri); // use AbsoluteUri to workaround bug in WebBrowser that calls Uri.ToString instead of Uri.AbsoluteUri leading to escaping errors. } public IAuthorizationState Authorization { get; set; } diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml b/samples/OAuthConsumerWpf/MainWindow.xaml index b4a6959..825de07 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml +++ b/samples/OAuthConsumerWpf/MainWindow.xaml @@ -144,6 +144,7 @@ <RowDefinition Height="auto" /> <RowDefinition Height="auto" /> <RowDefinition Height="auto" /> + <RowDefinition Height="auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> @@ -151,41 +152,43 @@ <ColumnDefinition Width="*" /> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> - <Label Grid.Row="1">Token Endpoint URL</Label> - <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" /> - <Label Grid.Row="2" Grid.Column="2">GET</Label> - <Label Grid.Row="0">Grant Type</Label> - <ComboBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" x:Name="flowBox" SelectedIndex="0"> + <Label Grid.Row="1" TabIndex="202">Token Endpoint URL</Label> + <TextBox Grid.Row="1" Grid.Column="1" x:Name="wrapTokenUrlBox" Text="http://localhost:18916/OAuthTokenEndpoint.ashx" TabIndex="203" /> + <Label Grid.Row="1" Grid.Column="2" TabIndex="204">POST</Label> + <Label Grid.Row="2" TabIndex="205">User Authorization URL</Label> + <TextBox Grid.Row="2" Grid.Column="1" x:Name="wrapAuthorizationUrlBox" Text="http://localhost:18916/Account/Authorize" TabIndex="206" /> + <Label Grid.Row="2" Grid.Column="2" TabIndex="207">GET</Label> + <Label Grid.Row="0" TabIndex="200">Grant Type</Label> + <ComboBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" x:Name="flowBox" SelectedIndex="0" TabIndex="201"> <ComboBox.Items> <ComboBoxItem>Authorization Code</ComboBoxItem> <ComboBoxItem>Resource Owner Basic Credentials</ComboBoxItem> <ComboBoxItem>Access Code (direct)</ComboBoxItem> </ComboBox.Items> </ComboBox> - <Label Grid.Row="3">Resource URL</Label> - <TextBox Grid.Row="3" Grid.Column="1" x:Name="wrapResourceUrlBox" Text="https://graph.facebook.com/me" /> - <ComboBox Grid.Row="3" Grid.Column="2" x:Name="wrapResourceHttpMethodList" SelectedIndex="0"> + <Label Grid.Row="3" TabIndex="207">Resource URL</Label> + <TextBox Grid.Row="3" Grid.Column="1" x:Name="wrapResourceUrlBox" Text="http://localhost:18916/" TabIndex="208" /> + <ComboBox Grid.Row="3" Grid.Column="2" x:Name="wrapResourceHttpMethodList" SelectedIndex="0" TabIndex="209"> <ComboBox.Items> <ComboBoxItem>GET w/ header</ComboBoxItem> <ComboBoxItem>GET w/ querystring</ComboBoxItem> <ComboBoxItem>POST</ComboBoxItem> </ComboBox.Items> </ComboBox> - <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" Text="1df77e64055c4d7d3583cefdf2bc62d7"/> - <Label Grid.Row="6">OAuth 2.0 version</Label> - <ComboBox Grid.Row="6" Grid.Column="1" SelectedIndex="0" x:Name="wrapVersion"> + <Label Grid.Row="4" TabIndex="210">Client Identifier</Label> + <TextBox Grid.Row="4" Grid.Column="1" x:Name="wrapClientIdentifierBox" Grid.ColumnSpan="2" Text="a" TabIndex="211" /> + <Label Grid.Row="5" TabIndex="212">Client Secret</Label> + <TextBox Grid.Row="5" Grid.Column="1" x:Name="wrapClientSecretBox" Grid.ColumnSpan="2" Text="b" TabIndex="213" /> + <Label Grid.Row="6" TabIndex="214">Scope</Label> + <TextBox Grid.Row="6" Grid.Column="1" x:Name="wrapScopeBox" TabIndex="215" Text="some scope" /> + <Label Grid.Row="7" TabIndex="216">OAuth 2.0 version</Label> + <ComboBox Grid.Row="7" Grid.Column="1" SelectedIndex="0" x:Name="wrapVersion" TabIndex="217"> <ComboBox.Items> <ComboBoxItem>2.0 DRAFT 9</ComboBoxItem> </ComboBox.Items> </ComboBox> - <Button Grid.Row="7" Grid.Column="1" x:Name="wrapBeginButton" Click="wrapBeginButton_Click">Begin</Button> - <TextBox Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="3" Name="wrapResultsBox" IsReadOnly="True" /> + <Button Grid.Row="8" Grid.Column="1" x:Name="wrapBeginButton" Click="wrapBeginButton_Click" TabIndex="218">Begin</Button> + <TextBox Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="3" Name="wrapResultsBox" IsReadOnly="True" TabIndex="219"/> </Grid> </TabItem> </TabControl> diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml.cs b/samples/OAuthConsumerWpf/MainWindow.xaml.cs index d698ce0..46a5f06 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml.cs +++ b/samples/OAuthConsumerWpf/MainWindow.xaml.cs @@ -29,7 +29,11 @@ using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.Samples.OAuthConsumerWpf.WcfSampleService; + + using OAuth2; + using OAuth2 = DotNetOpenAuth.OAuth2; + using ProtocolVersion = DotNetOpenAuth.OAuth.ProtocolVersion; /// <summary> /// Interaction logic for MainWindow.xaml @@ -213,8 +217,10 @@ ////var client = new DotNetOpenAuth.OAuth2.WebAppClient(authServer); ////client.PrepareRequestUserAuthorization(); var client = new OAuth2.UserAgentClient(authServer, wrapClientIdentifierBox.Text); + client.ClientSecret = wrapClientSecretBox.Text; - var authorizePopup = new Authorize2(client); + var authorization = new AuthorizationState { Scope = wrapScopeBox.Text }; + var authorizePopup = new Authorize2(client, authorization); authorizePopup.Owner = this; bool? result = authorizePopup.ShowDialog(); if (result.HasValue && result.Value) { @@ -237,6 +243,8 @@ } } catch (DotNetOpenAuth.Messaging.ProtocolException ex) { MessageBox.Show(this, ex.Message); + } catch (WebException ex) { + MessageBox.Show(this, ex.Message); } } } |