title: Add Authentication to a Request to REST Web Service?
body: <p>I am using <a href="http://aspnet.codeplex.com/releases/view/24644" rel="nofollow noreferrer">WCF REST Startkit</a> to create a test REST web service. To test it, I create a simple Console application with HTTPClient (provided by the kit) and HttpResponseMessage to make a request to the REST service. Here are some codes:</p>
  
  <pre><code>HttpClient client = new HttpClient(argsParser.BaseAddress);
  HttpResponseMessage resp = client.Get(argsParser.URI);
  Console.WriteLine(@"READING DATA FROM {0}{1}", 
    argsParser.BaseAddress, 
    argsParser.URI.Length == 0 ? @"" : string.Format(@"/{0}", 
    argsParse.URI));
  resp.EnsureStatusIsSuccessful();
  string contentType = resp.Content.ContentType;
  Console.WriteLine("CONTENT TYPE: {0}", contentType);
  string content = resp.Content.ReadAsString();
  Console.WriteLine(
  @"CONTENT: {0}", content);
  </code></pre>
  
  <p>where argsParser is my argument parser class to get base address and URI. It works fine as I said with my REST service in our intranet. However, when I used the test app with a web REST service such as Twitter REST service, I got exceptions.</p>
  
  <p>I think this is caused by my work network settings. <a href="http://www.bluecoat.com/" rel="nofollow noreferrer">BlueCode</a> security has been implemented as an enforcement to all browsers/http requests at work. I have to type in my user/pwd in a prompt window when my browser is accessing to a web REST service like Twitter's first time. After I provide my authentication information, the browser works fine.</p>
  
  <p>So I guess that with HttpClient and HTTPResponseMessage instances created in my console application, I may need to add/attach some authentication information to them. I am not sure what classes or APIs I need to provide the required authentication information?</p>