Hello everyone,
I am new to dynamics 365 and I have recently tried to develop a console job to manipulate opportunities on dynamics 365 platform, however, I am not able to connect.
It gives me this error when I run the app:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Part of the code for connection:
IOrganizationService service;
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "****@******onmicrosoft.com";
credentials.UserName.Password = "*************";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
service = new OrganizationServiceProxy(new Uri("https://**************************************.svc"), null, credentials, null);
if(service != null)
{
Guid userID = ((WhoAmIResponse)service.Execute(new WhoAmIRequest())).UserId;
if(userID != Guid.Empty)
{
Console.WriteLine("Connection successful");
}
}
else
{
Console.WriteLine("FAILED");
}
Here is a screenshot

I have tried adjusting the time zone and updating the NuGet packages but the error persists.
Thanks.