namespace OAuthServiceProvider.Code {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth.ChannelElements;
using DotNetOpenAuth.OAuth.Messages;
///
/// A custom class that will cause the OAuth library to use our custom message types
/// where we have them.
///
public class CustomOAuthMessageFactory : OAuthServiceProviderMessageFactory {
///
/// Initializes a new instance of the class.
///
/// The token manager instance to use.
public CustomOAuthMessageFactory(IServiceProviderTokenManager tokenManager)
: base(tokenManager) {
}
public override IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary fields) {
var message = base.GetNewRequestMessage(recipient, fields);
// inject our own type here to replace the standard one
if (message is UnauthorizedTokenRequest) {
message = new RequestScopedTokenMessage(recipient, message.Version);
}
return message;
}
}
}