Hello @Fortecho Solutions Ltd,
Thank you for your response.
I understand that after adding the line Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
to your code, the error "HttpRequestException: SocketException: An existing connection was forcibly closed by the remote host" was resolved. I appreciate the update on this matter.
Regarding the Entra app registration, I see that you have registered the application with the supported account types set to "Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts (e.g., Skype, Xbox)." This means your application can be used by all users with a work or school account, as well as personal Microsoft accounts. But users are getting an error AADSTS50020 when they login with Hotmail account.
To address the issue you're experiencing, please refer to the following Microsoft documentation and review the suggested solutions:
Error Code AADSTS50020 - User account identity provider does not exist
Based on your user behavior, it appears that your scenario falls under Cause 3 as documented. Your current code looks like this:
var app = ConfidentialClientApplicationBuilder.Create(clientId)
.WithClientSecret(clientSecret)
.WithAuthority(new Uri($"https://login.microsoftonline.com/{tenantId}"))
.Build();
If you are targeting the /tenantID
endpoint, encountering this error message is expected. Instead, you should use the https://login.microsoftonline.com/common
endpoint.
Please update your code accordingly:
var app = ConfidentialClientApplicationBuilder.Create(clientId)
.WithClientSecret(clientSecret)
.WithAuthority(new Uri("https://login.microsoftonline.com/common"))
.Build();
This change should help resolve the issue.
If the issue persists, I recommend that you review the other causes mentioned in the document linked above and let us know the update.
I hope this information is helpful. Please feel free to reach out if you have any further questions.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.
Thanks,
Raja Pothuraju.