diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-08 16:22:58 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-08 16:22:58 -0700 |
commit | d9c0ee017807cc17132e9c760d274afffc9b981c (patch) | |
tree | 28a79463a760a10c4d67cbac48f9a6af5cd25b32 /samples/OAuthConsumer | |
parent | 1c3247abc8fb37405d0602e5037b3cebbe8e944a (diff) | |
download | DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.zip DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.tar.gz DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.tar.bz2 |
Split up ITokenManager into two derived interfaces to better fit Consumer and Service Provider scenarios.
Diffstat (limited to 'samples/OAuthConsumer')
-rw-r--r-- | samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs | 2 | ||||
-rw-r--r-- | samples/OAuthConsumer/GoogleAddressBook.aspx.cs | 5 | ||||
-rw-r--r-- | samples/OAuthConsumer/SampleWcf.aspx.cs | 4 | ||||
-rw-r--r-- | samples/OAuthConsumer/Twitter.aspx.cs | 9 |
4 files changed, 10 insertions, 10 deletions
diff --git a/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs b/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs index f36a396..e2b2876 100644 --- a/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs +++ b/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs @@ -10,7 +10,7 @@ using System.Diagnostics; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; -public class InMemoryTokenManager : ITokenManager { +public class InMemoryTokenManager : IConsumerTokenManager { private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>(); public InMemoryTokenManager(string consumerKey, string consumerSecret) { diff --git a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs index 838b286..f4aa090 100644 --- a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs +++ b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs @@ -6,6 +6,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; using DotNetOpenAuth.ApplicationBlock; +using DotNetOpenAuth.OAuth; /// <summary> /// A page to demonstrate downloading a Gmail address book using OAuth. @@ -15,7 +16,7 @@ public partial class GoogleAddressBook : System.Web.UI.Page { if (!IsPostBack) { if (Session["TokenManager"] != null) { InMemoryTokenManager tokenManager = (InMemoryTokenManager)Session["TokenManager"]; - var google = GoogleConsumer.CreateWebConsumer(tokenManager, tokenManager.ConsumerKey); + var google = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager); var accessTokenResponse = google.ProcessUserAuthorization(); if (accessTokenResponse != null) { @@ -51,7 +52,7 @@ public partial class GoogleAddressBook : System.Web.UI.Page { InMemoryTokenManager tokenManager = new InMemoryTokenManager(consumerKeyBox.Text, consumerSecretBox.Text); Session["TokenManager"] = tokenManager; - var google = GoogleConsumer.CreateWebConsumer(tokenManager, consumerKeyBox.Text); + var google = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager); GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts); } } diff --git a/samples/OAuthConsumer/SampleWcf.aspx.cs b/samples/OAuthConsumer/SampleWcf.aspx.cs index e733970..7572dd8 100644 --- a/samples/OAuthConsumer/SampleWcf.aspx.cs +++ b/samples/OAuthConsumer/SampleWcf.aspx.cs @@ -109,9 +109,7 @@ public partial class SampleWcf : System.Web.UI.Page { new HmacSha1SigningBindingElement(), }, }, - tokenManager) { - ConsumerKey = consumerKey, - }; + tokenManager); return consumer; } diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs index 354fe69..550ed4a 100644 --- a/samples/OAuthConsumer/Twitter.aspx.cs +++ b/samples/OAuthConsumer/Twitter.aspx.cs @@ -9,6 +9,7 @@ using System.Web.UI.WebControls; using System.Xml.Linq; using System.Xml.XPath; using DotNetOpenAuth.ApplicationBlock; +using DotNetOpenAuth.OAuth; public partial class Twitter : System.Web.UI.Page { private string AccessToken { @@ -34,9 +35,9 @@ public partial class Twitter : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { - if (TokenManager != null) { + if (this.TokenManager != null) { InMemoryTokenManager tokenManager = (InMemoryTokenManager)Session["TokenManager"]; - var twitter = TwitterConsumer.CreateWebConsumer(tokenManager, tokenManager.ConsumerKey); + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, tokenManager); var accessTokenResponse = twitter.ProcessUserAuthorization(); if (accessTokenResponse != null) { @@ -56,12 +57,12 @@ public partial class Twitter : System.Web.UI.Page { return; } - var twitter = TwitterConsumer.CreateWebConsumer(this.TokenManager, this.TokenManager.ConsumerKey); + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); twitter.Channel.Send(twitter.PrepareRequestUserAuthorization()); } protected void downloadUpdates_Click(object sender, EventArgs e) { - var twitter = TwitterConsumer.CreateWebConsumer(this.TokenManager, this.TokenManager.ConsumerKey); + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); XPathDocument updates = new XPathDocument(TwitterConsumer.GetUpdates(twitter, AccessToken).CreateReader()); XPathNavigator nav = updates.CreateNavigator(); var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>() |