I am successfully integrated the Microsoft Account login with Asp.net Application and working fine with the office 365 email Ids, but I am getting below error while login with Email id which is Secured by Duo Two-Factor Authentication.
"The remote server returned an error: (400) Bad Request.,"
when I tried on postman the error is
"AADSTS50158: External security challenge not satisfied. User will be redirected to another page or authentication provider to satisfy additional authentication challenges"
but when I am going to direct login from browser after inserting the credentials of Microsoft account it redirects to Duo page for Duo push which is fine.
but when I am trying to login with my Asp.net application after inserting Microsoft Credentials it is not redirecting to Duo Push and throwing error "The remote server returned an error: (400) Bad Request.,"
The code is below to call API

Bhavesh RavalPosted Oct 23, 2023, 12:24 PM
Login errors when integrating with Microsoft Office 365 in an ASP.NET application can occur for a variety of reasons. To help you troubleshoot and resolve the issue, here are some common steps and considerations:
Check Application Registration:
App Permissions:
Redirect URIs:
Error Details:
Token Expiration:
Code Configuration:
API Endpoint URLs:
Logging:
Firewall and Network Issues:
Library and SDK Versions:
Consent and User Permissions:
Token and Session Management:
If you can provide more specific information about the error message or the code you are using, I can offer more targeted guidance. Additionally, consulting Microsoft's official documentation and developer resources can be helpful in resolving integration issues with Office 365 in ASP.NET applications.
manish kashyapPosted Oct 27, 2023, 6:41 AM
Thanks Bhavesh for your reply.
The Error Message is
"AADSTS50158: External security challenge not satisfied. User will be redirected to another page or authentication provider to satisfy additional authentication challenges"
Points to be noted that when I am login with Office 365 Email ID which is not secured with DUO authentication then it is working fine, Problem is with the Office 365 Email ID which is secured with DUO authentication I am facing this Error Message.
Also when I am login that email Id from Browser then it is working fine i.e. after successfull Microsoft login it is redirecting to DUO account which is fine.
I am using below code