diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-18 15:45:13 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-18 15:45:13 -0700 |
commit | 214b304aa178d286e440e6458e2ae173a64193b1 (patch) | |
tree | b1929806a8cec9c7f7430e3e07e2359975f3dbed | |
parent | c624d966756fcd69928565588445026efa31b4f3 (diff) | |
download | DotNetOpenAuth-214b304aa178d286e440e6458e2ae173a64193b1.zip DotNetOpenAuth-214b304aa178d286e440e6458e2ae173a64193b1.tar.gz DotNetOpenAuth-214b304aa178d286e440e6458e2ae173a64193b1.tar.bz2 |
Trimmed out some excess client sample code.
-rw-r--r-- | samples/OAuthConsumerWpf/MainWindow.xaml.cs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml.cs b/samples/OAuthConsumerWpf/MainWindow.xaml.cs index b6ae52f..45f2f6c 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml.cs +++ b/samples/OAuthConsumerWpf/MainWindow.xaml.cs @@ -203,23 +203,15 @@ } try { - ////var client = new DotNetOpenAuth.OAuth2.WebAppClient(authServer); - ////client.PrepareRequestUserAuthorization(); - var client = new OAuth2.UserAgentClient(authServer, oauth2ClientIdentifierBox.Text); - client.ClientSecret = oauth2ClientSecretBox.Text; + var client = new OAuth2.UserAgentClient(authServer, oauth2ClientIdentifierBox.Text, oauth2ClientSecretBox.Text); var authorization = new AuthorizationState { Scope = oauth2ScopeBox.Text }; var authorizePopup = new Authorize2(client, authorization); authorizePopup.Owner = this; bool? result = authorizePopup.ShowDialog(); if (result.HasValue && result.Value) { - // One method of OAuth authorization is to tack the ?access_token= onto the query string. - var address = new Uri(oauth2ResourceUrlBox.Text); - address = new Uri(oauth2ResourceUrlBox.Text + (string.IsNullOrEmpty(address.Query) ? "?" : string.Empty) + "access_token=" + Uri.EscapeDataString(authorizePopup.Authorization.AccessToken)); - var request = (HttpWebRequest)WebRequest.Create(address); - - // This method tacks on the Authorization header - client.AuthorizeRequest(request, authorizePopup.Authorization); + var request = (HttpWebRequest)WebRequest.Create(oauth2ResourceUrlBox.Text); + client.AuthorizeRequest(request, authorization); request.Method = oauth2ResourceHttpMethodList.SelectedIndex < 2 ? "GET" : "POST"; using (var resourceResponse = request.GetResponse()) { @@ -230,7 +222,7 @@ } else { return; } - } catch (DotNetOpenAuth.Messaging.ProtocolException ex) { + } catch (Messaging.ProtocolException ex) { MessageBox.Show(this, ex.Message); } catch (WebException ex) { MessageBox.Show(this, ex.Message); |