diff options
Diffstat (limited to 'src/DotNetOAuth/Consumer.cs')
-rw-r--r-- | src/DotNetOAuth/Consumer.cs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/DotNetOAuth/Consumer.cs b/src/DotNetOAuth/Consumer.cs index c0fe705..08320c3 100644 --- a/src/DotNetOAuth/Consumer.cs +++ b/src/DotNetOAuth/Consumer.cs @@ -130,20 +130,7 @@ namespace DotNetOAuth { /// <param name="accessToken">The access token that permits access to the protected resource.</param>
/// <returns>The initialized WebRequest object.</returns>
public WebRequest CreateAuthorizedRequest(ServiceProviderEndpoint endpoint, string accessToken) {
- if (endpoint == null) {
- throw new ArgumentNullException("endpoint");
- }
- if (String.IsNullOrEmpty(accessToken)) {
- throw new ArgumentNullException("accessToken");
- }
-
- AccessProtectedResourcesMessage message = new AccessProtectedResourcesMessage(endpoint) {
- AccessToken = accessToken,
- TokenSecret = this.TokenManager.GetTokenSecret(accessToken),
- ConsumerKey = this.ConsumerKey,
- ConsumerSecret = this.ConsumerSecret,
- };
-
+ IDirectedProtocolMessage message = this.CreateAuthorizedRequestInternal(endpoint, accessToken);
WebRequest wr = this.Channel.InitializeRequest(message);
return wr;
}
@@ -157,6 +144,19 @@ namespace DotNetOAuth { /// <returns>The initialized WebRequest object.</returns>
/// <exception cref="WebException">Thrown if the request fails for any reason after it is sent to the Service Provider.</exception>
public Response SendAuthorizedRequest(ServiceProviderEndpoint endpoint, string accessToken) {
+ IDirectedProtocolMessage message = this.CreateAuthorizedRequestInternal(endpoint, accessToken);
+ HttpWebRequest wr = this.Channel.InitializeRequest(message);
+ return this.WebRequestHandler.GetResponse(wr);
+ }
+
+ /// <summary>
+ /// Creates a web request prepared with OAuth authorization
+ /// that may be further tailored by adding parameters by the caller.
+ /// </summary>
+ /// <param name="endpoint">The URL and method on the Service Provider to send the request to.</param>
+ /// <param name="accessToken">The access token that permits access to the protected resource.</param>
+ /// <returns>The initialized WebRequest object.</returns>
+ internal AccessProtectedResourcesMessage CreateAuthorizedRequestInternal(ServiceProviderEndpoint endpoint, string accessToken) {
if (endpoint == null) {
throw new ArgumentNullException("endpoint");
}
@@ -171,9 +171,7 @@ namespace DotNetOAuth { ConsumerSecret = this.ConsumerSecret,
};
- HttpWebRequest wr = this.Channel.InitializeRequest(message);
- Response response = new Response((HttpWebResponse)wr.GetResponse());
- return response;
+ return message;
}
}
}
|