summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-05-02 19:57:43 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-05-02 19:57:43 -0700
commit70797cd7185a34e19d97788dc0459253a78492e7 (patch)
tree357a071c97b0df416a0e09bc9fff045032a7569c /src
parent46f358e14ab156b28fbb81ccc278a9324c35c919 (diff)
parent2707e2c728f560e30e1559b266b6eb54ea2b1fee (diff)
downloadDotNetOpenAuth-70797cd7185a34e19d97788dc0459253a78492e7.zip
DotNetOpenAuth-70797cd7185a34e19d97788dc0459253a78492e7.tar.gz
DotNetOpenAuth-70797cd7185a34e19d97788dc0459253a78492e7.tar.bz2
Merge branch 'v3.0' into v3.1v3.1.0.9122
Conflicts: src/version.txt
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/OAuth/ConsumerBase.cs70
1 files changed, 49 insertions, 21 deletions
diff --git a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
index adf8602..64142f7 100644
--- a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
+++ b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
@@ -73,7 +73,35 @@ namespace DotNetOpenAuth.OAuth {
/// <param name="accessToken">The access token that permits access to the protected resource.</param>
/// <returns>The initialized WebRequest object.</returns>
public HttpWebRequest PrepareAuthorizedRequest(MessageReceivingEndpoint endpoint, string accessToken) {
+ Contract.Requires(endpoint != null);
+ Contract.Requires(!String.IsNullOrEmpty(accessToken));
+ ErrorUtilities.VerifyArgumentNotNull(endpoint, "endpoint");
+ ErrorUtilities.VerifyNonZeroLength(accessToken, "accessToken");
+
+ return PrepareAuthorizedRequest(endpoint, accessToken, EmptyDictionary<string, string>.Instance);
+ }
+
+ /// <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>
+ /// <param name="extraData">Extra parameters to include in the message. Must not be null, but may be empty.</param>
+ /// <returns>The initialized WebRequest object.</returns>
+ public HttpWebRequest PrepareAuthorizedRequest(MessageReceivingEndpoint endpoint, string accessToken, IDictionary<string, string> extraData) {
+ Contract.Requires(endpoint != null);
+ Contract.Requires(!String.IsNullOrEmpty(accessToken));
+ Contract.Requires(extraData != null);
+ ErrorUtilities.VerifyArgumentNotNull(endpoint, "endpoint");
+ ErrorUtilities.VerifyNonZeroLength(accessToken, "accessToken");
+ ErrorUtilities.VerifyArgumentNotNull(extraData, "extraData");
+
IDirectedProtocolMessage message = this.CreateAuthorizingMessage(endpoint, accessToken);
+ foreach (var pair in extraData) {
+ message.ExtraData.Add(pair);
+ }
+
HttpWebRequest wr = this.OAuthChannel.InitializeRequest(message);
return wr;
}
@@ -106,27 +134,6 @@ namespace DotNetOpenAuth.OAuth {
/// <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>
- public AccessProtectedResourceRequest CreateAuthorizingMessage(MessageReceivingEndpoint endpoint, string accessToken) {
- Contract.Requires(endpoint != null);
- Contract.Requires(!String.IsNullOrEmpty(accessToken));
- ErrorUtilities.VerifyArgumentNotNull(endpoint, "endpoint");
- ErrorUtilities.VerifyNonZeroLength(accessToken, "accessToken");
-
- AccessProtectedResourceRequest message = new AccessProtectedResourceRequest(endpoint) {
- AccessToken = accessToken,
- ConsumerKey = this.ConsumerKey,
- };
-
- return message;
- }
-
- /// <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>
/// <exception cref="WebException">Thrown if the request fails for any reason after it is sent to the Service Provider.</exception>
public IncomingWebResponse PrepareAuthorizedRequestAndSend(MessageReceivingEndpoint endpoint, string accessToken) {
IDirectedProtocolMessage message = this.CreateAuthorizingMessage(endpoint, accessToken);
@@ -147,6 +154,27 @@ namespace DotNetOpenAuth.OAuth {
#endregion
/// <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>
+ protected internal AccessProtectedResourceRequest CreateAuthorizingMessage(MessageReceivingEndpoint endpoint, string accessToken) {
+ Contract.Requires(endpoint != null);
+ Contract.Requires(!String.IsNullOrEmpty(accessToken));
+ ErrorUtilities.VerifyArgumentNotNull(endpoint, "endpoint");
+ ErrorUtilities.VerifyNonZeroLength(accessToken, "accessToken");
+
+ AccessProtectedResourceRequest message = new AccessProtectedResourceRequest(endpoint) {
+ AccessToken = accessToken,
+ ConsumerKey = this.ConsumerKey,
+ };
+
+ return message;
+ }
+
+ /// <summary>
/// Prepares an OAuth message that begins an authorization request that will
/// redirect the user to the Service Provider to provide that authorization.
/// </summary>