blob: 4dc3dcc83a5aa975fa79bed2f5e2175d8adf1792 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
//-----------------------------------------------------------------------
// <copyright file="DotNetOpenAuthWebConsumer.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.AspNet.Clients {
using System;
using System.Collections.Generic;
using System.Net;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth;
using DotNetOpenAuth.OAuth.ChannelElements;
using DotNetOpenAuth.OAuth.Messages;
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);
}
}
}
|