summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs')
-rw-r--r--src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs b/src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs
new file mode 100644
index 0000000..b66f0b1
--- /dev/null
+++ b/src/DotNetOpenAuth.Web/Clients/OAuth/DotNetOpenAuthWebConsumer.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using DotNetOpenAuth.Messaging;
+using DotNetOpenAuth.OAuth;
+using DotNetOpenAuth.OAuth.ChannelElements;
+using DotNetOpenAuth.OAuth.Messages;
+
+namespace DotNetOpenAuth.Web.Clients
+{
+ public class DotNetOpenAuthWebConsumer : IOAuthWebWorker
+ {
+ private readonly WebConsumer _webConsumer;
+
+ public DotNetOpenAuthWebConsumer(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
+ {
+ if (serviceDescription == null)
+ {
+ throw new ArgumentNullException("consumer");
+ }
+
+ if (tokenManager == null)
+ {
+ throw new ArgumentNullException("tokenManager");
+ }
+
+ _webConsumer = new WebConsumer(serviceDescription, tokenManager);
+ }
+
+ public void RequestAuthentication(Uri callback)
+ {
+ var redirectParameters = new Dictionary<string, string>() { { "force_login", "false" } };
+ UserAuthorizationRequest request = _webConsumer.PrepareRequestUserAuthorization(callback, null, redirectParameters);
+ _webConsumer.Channel.PrepareResponse(request).Send();
+ }
+
+ public AuthorizedTokenResponse ProcessUserAuthorization()
+ {
+ return _webConsumer.ProcessUserAuthorization();
+ }
+
+ public HttpWebRequest PrepareAuthorizedRequest(MessageReceivingEndpoint profileEndpoint, string accessToken)
+ {
+ return _webConsumer.PrepareAuthorizedRequest(profileEndpoint, accessToken);
+ }
+ }
+} \ No newline at end of file