/// <summary>
        /// Gets OAuth authorization header.
        /// </summary>
        protected virtual string GetAuthorizationHeader()
        {
            //
            // Make sure that the parameters array contains
            // mulitpart keys if we're dealing with a buggy
            // OAuth implementation (I'm looking at you Flickr).
            //
            // These normally shouldn't be included: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
            //
            var ps = new Dictionary <string, string> (Parameters);

            if (includeMultipartsInSignature)
            {
                foreach (var p in Multiparts)
                {
                    if (!string.IsNullOrEmpty(p.TextData))
                    {
                        ps [p.Name] = p.TextData;
                    }
                }
            }

            return(OAuth1.GetAuthorizationHeader(
                       Method,
                       Url,
                       ps,
                       Account.Properties ["oauth_consumer_key"],
                       Account.Properties ["oauth_consumer_secret"],
                       Account.Properties ["oauth_token"],
                       Account.Properties ["oauth_token_secret"]));
        }
        /// <summary>
        /// Gets the response.
        /// </summary>
        /// <returns>
        /// The response.
        /// </returns>
        public override Task <Response> GetResponseAsync(CancellationToken cancellationToken)
        {
            //
            // Make sure we have an account
            //
            if (Account == null)
            {
                throw new InvalidOperationException("You must specify an Account for this request to proceed");
            }

            //
            // Sign the request before getting the response
            //
            var req = GetPreparedWebRequest();

            //
            // Make sure that the parameters array contains
            // mulitpart keys if we're dealing with a buggy
            // OAuth implementation (I'm looking at you Flickr).
            //
            // These normally shouldn't be included: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
            //
            var ps = new Dictionary <string, string> (Parameters);

            if (includeMultipartsInSignature)
            {
                foreach (var p in Multiparts)
                {
                    if (!string.IsNullOrEmpty(p.TextData))
                    {
                        ps [p.Name] = p.TextData;
                    }
                }
            }

            //
            // Authorize it
            //
            var authorization = OAuth1.GetAuthorizationHeader(
                Method,
                Url,
                ps,
                Account.Properties ["oauth_consumer_key"],
                Account.Properties ["oauth_consumer_secret"],
                Account.Properties ["oauth_token"],
                Account.Properties ["oauth_token_secret"]);

            req.Headers [HttpRequestHeader.Authorization] = authorization;

            return(base.GetResponseAsync(cancellationToken));
        }
Exemple #3
0
        /// <summary>
        /// Gets OAuth authorization header.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Make sure that the parameters array contains mulitpart keys if we're dealing with a buggy
        /// OAuth implementation (such as Flickr).
        /// </para>
        /// <para>
        /// These normally shouldn't be included: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
        /// </para>
        /// </remarks>
        protected virtual string GetAuthorizationHeader()
        {
            var ps = new Dictionary <string, string>(Parameters);

            if (includeMultipartsInSignature)
            {
                foreach (var p in Multiparts)
                {
                    if (!string.IsNullOrEmpty(p.TextData))
                    {
                        ps[p.Name] = p.TextData;
                    }
                }
            }

            return(OAuth1.GetAuthorizationHeader(
                       Method,
                       Url,
                       ps,
                       Account.Properties["oauth_consumer_key"],
                       Account.Properties["oauth_consumer_secret"],
                       Account.Properties["oauth_token"],
                       Account.Properties["oauth_token_secret"]));
        }