//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth.Messages { using System; using System.Globalization; using DotNetOpenAuth.Messaging; /// /// A direct message sent by the Consumer to exchange an authorized Request Token /// for an Access Token and Token Secret. /// /// /// The class is sealed because the OAuth spec forbids adding parameters to this message. /// public sealed class AuthorizedTokenRequest : SignedMessageBase, ITokenContainingMessage { /// /// Initializes a new instance of the class. /// /// The URI of the Service Provider endpoint to send this message to. /// The OAuth version. internal AuthorizedTokenRequest(MessageReceivingEndpoint serviceProvider, Version version) : base(MessageTransport.Direct, serviceProvider, version) { } /// /// Gets or sets the Token. /// string ITokenContainingMessage.Token { get { return this.RequestToken; } set { this.RequestToken = value; } } /// /// Gets or sets the verification code received by the Consumer from the Service Provider /// in the property. /// [MessagePart("oauth_verifier", IsRequired = true, AllowEmpty = false, MinVersion = Protocol.V10aVersion)] public string VerificationCode { get; set; } /// /// Gets or sets the authorized Request Token used to obtain authorization. /// [MessagePart("oauth_token", IsRequired = true)] internal string RequestToken { get; set; } /// /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// protected override void EnsureValidMessage() { base.EnsureValidMessage(); if (this.ExtraData.Count > 0) { throw new ProtocolException(string.Format(CultureInfo.CurrentCulture, OAuthStrings.MessageNotAllowedExtraParameters, GetType().Name)); } } } }