/// <summary> /// Takes an existing httpwebrequest and modifies it's 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, this.ConsumerKey, this.ConsumerSecret, this.Token, this.TokenSecret, request.Method); request.Headers.Add(oauthHeader); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>sets up the correct credentials for this call</summary> ////////////////////////////////////////////////////////////////////// protected override void EnsureCredentials() { HttpWebRequest http = this.Request as HttpWebRequest; if (string.IsNullOrEmpty(this.factory.ConsumerKey) || string.IsNullOrEmpty(this.factory.ConsumerSecret)) { throw new GDataRequestException("ConsumerKey and ConsumerSecret must be provided to use GOAuthRequestFactory"); } string oauthHeader = OAuthUtil.GenerateHeader(http.RequestUri, this.factory.ConsumerKey, this.factory.ConsumerSecret, this.factory.Token, this.factory.TokenSecret, http.Method); this.Request.Headers.Remove("Authorization"); // needed? this.Request.Headers.Add(oauthHeader); }