diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-28 22:29:54 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-28 22:32:55 -0700 |
commit | 44cc811c6af84fe390454b7beaa4b43ece7a8883 (patch) | |
tree | bb52f021f3078a4330e7b0f30930453a8e758d7e | |
parent | aff8bdb3b5b67fbb9f5879843d657b120b2128a7 (diff) | |
download | DotNetOpenAuth-44cc811c6af84fe390454b7beaa4b43ece7a8883.zip DotNetOpenAuth-44cc811c6af84fe390454b7beaa4b43ece7a8883.tar.gz DotNetOpenAuth-44cc811c6af84fe390454b7beaa4b43ece7a8883.tar.bz2 |
Added capability to add extra fields to request token message.
-rw-r--r-- | src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs | 2 | ||||
-rw-r--r-- | src/DotNetOAuth/Consumer.cs | 5 | ||||
-rw-r--r-- | src/DotNetOAuth/Messages/MessageBase.cs | 6 | ||||
-rw-r--r-- | src/DotNetOAuth/Messaging/MessagingUtilities.cs | 14 |
4 files changed, 25 insertions, 2 deletions
diff --git a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs index 5bd4629..ee574c9 100644 --- a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs +++ b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs @@ -39,7 +39,7 @@ namespace DotNetOAuth.Test { Coordinator coordinator = new Coordinator(
channel => {
consumer.Channel = channel;
- consumer.RequestUserAuthorization(new Uri("http://printer.example.com/request_token_ready"));
+ consumer.RequestUserAuthorization(new Uri("http://printer.example.com/request_token_ready"), null);
string accessToken = consumer.ProcessUserAuthorization();
var photoRequest = consumer.CreateAuthorizedRequestInternal(accessPhotoEndpoint, accessToken);
Response protectedPhoto = channel.RequestProtectedResource(photoRequest);
diff --git a/src/DotNetOAuth/Consumer.cs b/src/DotNetOAuth/Consumer.cs index d61eb0b..175d3d2 100644 --- a/src/DotNetOAuth/Consumer.cs +++ b/src/DotNetOAuth/Consumer.cs @@ -6,6 +6,7 @@ namespace DotNetOAuth {
using System;
+ using System.Collections.Generic;
using System.Net;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messages;
@@ -84,12 +85,14 @@ namespace DotNetOAuth { /// An optional Consumer URL that the Service Provider should redirect the
/// User Agent to upon successful authorization.
/// </param>
- public void RequestUserAuthorization(Uri callback) {
+ /// <param name="extraParameters">Extra parameters to add to the request token message. Optional.</param>
+ public void RequestUserAuthorization(Uri callback, IDictionary<string, string> extraParameters) {
// Obtain an unauthorized request token.
var requestToken = new RequestTokenMessage(this.ServiceProvider.RequestTokenEndpoint) {
ConsumerKey = this.ConsumerKey,
ConsumerSecret = this.ConsumerSecret,
};
+ requestToken.AddExtraFields(extraParameters);
var requestTokenResponse = this.Channel.Request<UnauthorizedRequestTokenMessage>(requestToken);
this.TokenManager.StoreNewRequestToken(this.ConsumerKey, requestTokenResponse.RequestToken, requestTokenResponse.TokenSecret, null/*TODO*/);
diff --git a/src/DotNetOAuth/Messages/MessageBase.cs b/src/DotNetOAuth/Messages/MessageBase.cs index e213346..58b3cbf 100644 --- a/src/DotNetOAuth/Messages/MessageBase.cs +++ b/src/DotNetOAuth/Messages/MessageBase.cs @@ -37,6 +37,12 @@ namespace DotNetOAuth.Messages { /// </summary>
private MessageReceivingEndpoint recipient;
+#if DEBUG
+ static MessageBase() {
+ LowSecurityMode = true;
+ }
+#endif
+
/// <summary>
/// Initializes a new instance of the <see cref="MessageBase"/> class.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/MessagingUtilities.cs b/src/DotNetOAuth/Messaging/MessagingUtilities.cs index 7793276..5ec157c 100644 --- a/src/DotNetOAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOAuth/Messaging/MessagingUtilities.cs @@ -13,6 +13,7 @@ namespace DotNetOAuth.Messaging { using System.Net;
using System.Text;
using System.Web;
+ using DotNetOAuth.Messaging.Reflection;
/// <summary>
/// A grab-bag of utility methods useful for the channel stack of the protocol.
@@ -139,6 +140,19 @@ namespace DotNetOAuth.Messaging { return new MessageReceivingEndpoint(request.Url, request.HttpMethod == "GET" ? HttpDeliveryMethod.GetRequest : HttpDeliveryMethod.PostRequest);
}
+ internal static void AddExtraFields(this IProtocolMessage message, IDictionary<string, string> extraParameters) {
+ if (message == null) {
+ throw new ArgumentNullException("message");
+ }
+
+ if (extraParameters != null) {
+ MessageDictionary messageDictionary = new MessageDictionary(message);
+ foreach (var pair in extraParameters) {
+ messageDictionary.Add(pair);
+ }
+ }
+ }
+
/// <summary>
/// Converts a <see cref="NameValueCollection"/> to an IDictionary<string, string>.
/// </summary>
|