示例#1
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///     Initializes a new instance of the OAuth2Client class.
 /// </summary>
 ///
 /// <remarks>
 ///     Anwar Javed, 10/16/2013 12:08 PM.
 /// </remarks>
 ///
 /// <param name="appID">
 ///     The consumer key.
 /// </param>
 /// <param name="appSecret">
 ///     The consumer secret.
 /// </param>
 /// <param name="credential">
 ///     The credential.
 /// </param>
 /// <param name="tokenAccessType">
 ///     The type of the token access.
 /// </param>
 ///-------------------------------------------------------------------------------------------------
 protected OAuth2Client(string appID, string appSecret, OAuth2TokenCredential credential, OAuth2TokenAccessType tokenAccessType = OAuth2TokenAccessType.Header)
 {
     this.AppID           = appID;
     this.AppSecret       = appSecret;
     this.Credential      = credential;
     this.TokenAccessType = tokenAccessType;
 }
示例#2
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Sets up the o authentication 2.
        /// </summary>
        ///
        /// <param name="request">
        ///     The request.
        /// </param>
        /// <param name="token">
        ///     The token.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        private void SetupOAuth2(RestRequest request, OAuth2TokenCredential token)
        {
            switch (this.TokenAccessType)
            {
            case OAuth2TokenAccessType.Querystring:
                request.Parameters.Add(this.OAuth2AccessTokenParameter, token.Token);
                break;

            default:
                string authHeader = "{0} {1}".FormatString(token.TokenType, token.Token);
                request.Headers["Authorization"] = authHeader;
                break;
            }
        }