//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2.Messages { using System; using System.Collections.Generic; using System.Linq; using System.Text; using ChannelElements; using Messaging; /// /// A message that accompanies an HTTP request to a resource server that provides authorization. /// /// /// In its current form, this class only accepts bearer access tokens. /// When support for additional access token types is added, this class should probably be refactored /// into derived types, where each derived type supports a particular access token type. /// internal class AccessProtectedResourceRequest : MessageBase, IAccessTokenCarryingRequest { /// /// Initializes a new instance of the class. /// /// The recipient. /// The version. internal AccessProtectedResourceRequest(Uri recipient, Version version) : base(version, MessageTransport.Direct, recipient) { this.HttpMethods = HttpDeliveryMethods.HttpVerbMask; } #region IAccessTokenCarryingRequest Members /// /// Gets or sets the access token. /// string IAccessTokenCarryingRequest.AccessToken { get { return this.AccessToken; } set { this.AccessToken = value; } } /// /// Gets or sets the authorization that the token describes. /// AccessToken IAccessTokenCarryingRequest.AuthorizationDescription { get; set; } /// /// Gets the authorization that the token describes. /// IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get { return ((IAccessTokenCarryingRequest)this).AuthorizationDescription; } } #endregion /// /// Gets the type of the access token. /// /// /// Always "bearer". /// [MessagePart("token_type", IsRequired = true)] internal static string TokenType { get { return Protocol.AccessTokenTypes.Bearer; } } /// /// Gets or sets the access token. /// /// The access token. [MessagePart("access_token", IsRequired = true)] internal string AccessToken { get; set; } } }