title: (401) Unauthorized Error working with Client Object Model
body: <p>I'm tryiing to retrieve a list of document libraries from a sharepoint site, here is my code, this is a windows app</p>
  
  <pre><code>public string[] GetDocumentLibraries(ClientContext ctx)
      {
          Collection&lt;string&gt; libraries = new Collection&lt;string&gt;();
          try
          {
              //Getting the site from the SP context
              Web oWebsite = ctx.Web;
              write("INFO: SP site gotten");
  
              //Getting the list collection from the SP site
              write("INFO: Getting the list collection from the SP site");
              ListCollection listCollect = oWebsite.Lists;
              write("INFO: Loading the list");
              ctx.Load(listCollect);
              write("INFO: Getting the list");
              ctx.ExecuteQuery();
              write("INFO: List Collection size: " + listCollect.Count);
  
              //Getting the list of document libraries
              foreach (List docLibList in oWebsite.Lists)
              {
                  if (docLibList.BaseTemplate == (int)ListTemplateType.DocumentLibrary)
                  {
                      write("INFO: Document Library: " + docLibList.Title);
                      libraries.Add(docLibList.Title);
                  }
              }
          }
          catch (Exception e)
          {
              write("ERROR: Error getting the list of document libraries, error detail " + e.Message + " " + e.StackTrace);
          }
  
          return libraries.ToArray();
      }
  </code></pre>
  
  <p>I had tried this code in three different SharePoint servers, it works in two of them, but in the third one I'm getting this exception</p>
  
  <pre><code>ERROR: Error getting the list of document libraries, error detail The remote server returned an error: (401) Unauthorized.    at System.Net.HttpWebRequest.GetResponse()
     at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
     at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
     at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
     at P_DocumentImporter.DocumentImporter.GetDocumentLibraries(ClientContext ctx)
  </code></pre>
  
  <p>And I'm sure the credentials are correct,</p>
  
  <p>Any clue about this,</p>
  
  <p>Thanks,</p>