/// <summary>
        /// Takes an existing httpwebrequest and modifies its headers according to
        /// the authentication system used.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public override void ApplyAuthenticationToRequest(HttpWebRequest request)
        {
            base.ApplyAuthenticationToRequest(request);

            string oauthHeader = OAuthUtil.GenerateHeader(
                request.RequestUri,
                request.Method,
                _parameters);

            request.Headers.Add(oauthHeader);
        }
Esempio n. 2
0
        /// <summary>
        /// sets up the correct credentials for this call.
        /// </summary>
        protected override void EnsureCredentials()
        {
            HttpWebRequest http = Request as HttpWebRequest;

            if (string.IsNullOrEmpty(_factory.ConsumerKey) || string.IsNullOrEmpty(_factory.ConsumerSecret))
            {
                throw new GDataRequestException("ConsumerKey and ConsumerSecret must be provided to use GOAuthRequestFactory");
            }

            string oauthHeader = OAuthUtil.GenerateHeader(
                http.RequestUri,
                _factory.ConsumerKey,
                _factory.ConsumerSecret,
                _factory.Token,
                _factory.TokenSecret,
                http.Method);

            Request.Headers.Remove("Authorization"); // needed?
            Request.Headers.Add(oauthHeader);
        }