An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail – System.ServiceModel.Security.MessageSecurityException – FaultException: Authentication Failure – Console Application C# Dynamics 365

While connecting with Dynamics 365 from Console Applications if you are getting the below error then read this blog for solution.
System.ServiceModel.Security.MessageSecurityException: ‘An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.’
FaultException: Authentication Failure
Solution
If Your Multi-Factor Authentication is enabled then this error normally gives error. Disable it using Azure Active Directory.
Open Azure Portal and click Azure Active Directory.

Now click Property Link and click Manage Security Defaults

Now click No for Enable Security Defaults. Click SAVE.

Now You will not get this error.