title: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail
body: <p>When I try to execute a CRM CRUD operation using a Console App, I'm getting the following error: </p>
  
  <blockquote>
    <p>System.ServiceModel.Security.MessageSecurityException
      HResult=0x80131501
      Message=An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
      Source=mscorlib</p>
  </blockquote>
  
  <pre><code>class Program
  {
  
      static void Main(string[] args)
      {
           IOrganizationService _serviceProxy = crmConnection();
  
           Entity con = new Entity("contact");
           con["lastname"] = "test"; 
           _serviceProxy.Create(con);
      }
      private static IOrganizationService crmConnection()
      {
      ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
      Uri oUri = new Uri("https://XXXXXXXX.api.crm.dynamics.com/XRMServices/2011/Organization.svc");          
      ClientCredentials clientCredentials = new ClientCredentials();
      clientCredentials.UserName.UserName = "XXXXXXXXXXXX";
      clientCredentials.UserName.Password = "XXXXXXXXXXXXXXXXXX";  
      OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(oUri, null,clientCredentials,null);
      _serviceProxy.Timeout = new TimeSpan(0, 10, 0);
      return _serviceProxy;
      }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p><a href="https://i.stack.imgur.com/TlgOh.png" rel="nofollow noreferrer">An unsecured or incorrectly secured fault was received from the other party</a></p>