I have followed all the step mentioned in this answer given by @Robert Muehsig and added the code in .net framework console app after running I am getting below error,
Microsoft.Identity.Client.MsalClientException: 'There was an error parsing WS-Trust response from the endpoint. This may occur if there is an issue with your ADFS configuration. See https://aka.ms/msal-net-iwa-troubleshooting for more details. Error Message: returned error: ID3242: The security token could not be authenticated or authorized. '
code part
var pcaOptions = new PublicClientApplicationOptions
{
ClientId = "ClientId",
TenantId = "TenantId"
};
var pca = PublicClientApplicationBuilder.CreateWithApplicationOptions(pcaOptions).Build();
var securePassword = new SecureString();
foreach (char c in "Password")
securePassword.AppendChar(c);
var cred = new NetworkCredential("Username", securePassword);
var authResult = await pca.AcquireTokenByUsernamePassword(new string[] { "https://outlook.office.com/EWS.AccessAsUser.All" }, cred.UserName, cred.SecurePassword).ExecuteAsync();
During registration I have set "Treat application as public client" true.
From postman I able to get token but if add it during debug point it will throw 401 error.
