title: Basic HTTP Authentication over HTTPS with WCF
body: <p>I’m calling a web service via WCF (w/ .NET 4.0) that requires basic HTTP authentication (with username and password.) over HTTPS.  While, I think I’ve got everything setup correctly, I’m getting a 401 error whenever I make the call to the service.  I monitored the HTTP traffic and noticed that WCF seems to be ignoring that I told it to use an authorization header with the username and password, as none is sent in the request.  Here’s my configuration below.  Any ideas?  Thanks!</p>
  
  <pre><code>   &lt;system.serviceModel&gt;
           &lt;bindings&gt;
                  &lt;basicHttpBinding&gt;
                         &lt;binding name="BasicAuthSecured"&gt;
                               &lt;security mode="Transport"&gt;
                                      &lt;transport clientCredentialType="Basic" /&gt;
                               &lt;/security&gt;
                         &lt;/binding&gt;
                         &lt;/basicHttpBinding&gt;
                  &lt;/bindings&gt;
           &lt;client&gt;
                  &lt;endpoint address="https://REMOVED FOR CONFIDENTIALITY"
              binding="basicHttpBinding" bindingConfiguration="BasicAuthSecured"
              contract="Five9.WsAdmin" name="WsAdminPort" /&gt;
           &lt;/client&gt;
           &lt;behaviors&gt;
                  &lt;serviceBehaviors&gt;
                         &lt;behavior name=""&gt;
                               &lt;serviceMetadata httpsGetEnabled="true"/&gt;
                               &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                         &lt;/behavior&gt;
                  &lt;/serviceBehaviors&gt;
           &lt;/behaviors&gt;
     &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>And here’s my code:</p>
  
  <pre><code>        var five_9_client = new WsAdminClient();
  
          five_9_client.ClientCredentials.UserName.UserName = “REMOVED FOR CONFIDENTIALITY";
          five_9_client.ClientCredentials.UserName.Password = "REMOVED FOR CONFIDENTIALITY";
  
          var call_log_response = five_9_client.getCallLogReport(call_log); //Bombing out here
  </code></pre>
  
  <p>I’m getting this exception:</p>
  
  <p>{"The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was ''."}</p>
  
  <p>With inner exception:</p>
  
  <p>{"The remote server returned an error: (401) Unauthorized."}</p>
  
  <p>With stack trace: </p>
  
  <p>at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
     at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
     at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
     at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)</p>