//----------------------------------------------------------------------- // // 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, IAuthorizationCarryingRequest { /// /// Initializes a new instance of the class. /// /// The recipient. /// The version. internal AccessProtectedResourceRequest(Uri recipient, Version version) : base(version, MessageTransport.Direct, recipient) { } /// /// Gets the type of the code or token. /// /// The type of the code or token. CodeOrTokenType IAuthorizationCarryingRequest.CodeOrTokenType { get { return CodeOrTokenType.AccessToken; } } /// /// Gets or sets the verification code or refresh/access token. /// /// The code or token. string IAuthorizationCarryingRequest.CodeOrToken { get { return this.AccessToken; } set { this.AccessToken = value; } } /// /// Gets or sets the authorization that the token describes. /// IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get; set; } /// /// Gets the type of the access token. /// /// /// Always "bearer". /// [MessagePart("token_type", IsRequired = true)] internal 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; } } }