diff options
Diffstat (limited to 'samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs')
-rw-r--r-- | samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs index 4bcb112..1dff5b6 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/YammerConsumer.cs @@ -13,12 +13,13 @@ namespace DotNetOpenAuth.ApplicationBlock { using System.Text; using System.Threading; using System.Threading.Tasks; + using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; - public static class YammerConsumer { + public class YammerConsumer : Consumer { /// <summary> /// The Consumer to use for accessing Google data APIs. /// </summary> @@ -28,6 +29,15 @@ namespace DotNetOpenAuth.ApplicationBlock { "https://www.yammer.com/oauth/authorize", "https://www.yammer.com/oauth/access_token"); + public YammerConsumer() { + this.ServiceProvider = ServiceDescription; + this.ConsumerKey = ConfigurationManager.AppSettings["YammerConsumerKey"]; + this.ConsumerSecret = ConfigurationManager.AppSettings["YammerConsumerSecret"]; + this.TemporaryCredentialStorage = HttpContext.Current != null + ? (ITemporaryCredentialStorage)new CookieTemporaryCredentialStorage() + : new MemoryTemporaryCredentialStorage(); + } + /// <summary> /// Gets a value indicating whether the Twitter consumer key and secret are set in the web.config file. /// </summary> @@ -37,16 +47,5 @@ namespace DotNetOpenAuth.ApplicationBlock { !string.IsNullOrEmpty(ConfigurationManager.AppSettings["yammerConsumerSecret"]); } } - - public static Consumer CreateConsumer(bool forWeb = true) { - string consumerKey = ConfigurationManager.AppSettings["yammerConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["yammerConsumerSecret"]; - if (IsConsumerConfigured) { - ITemporaryCredentialStorage storage = forWeb ? (ITemporaryCredentialStorage)new CookieTemporaryCredentialStorage() : new MemoryTemporaryCredentialStorage(); - return new Consumer(consumerKey, consumerSecret, ServiceDescription, storage); - } else { - throw new InvalidOperationException("No Yammer OAuth consumer key and secret could be found in web.config AppSettings."); - } - } } } |