Hi @Dumbre, Rohit
Thank you for posting your question in the Microsoft Q&A forum.
This is a common challenge many developers face when integrating OAuth flows. While the login and consent screens are managed by Microsoft and can't be directly modified to debounce or block extra clicks, there are several effective strategies you can implement on your end to protect your application against multiple callback issues:
-Disable the login button immediately after the first click.
A simple UI change helps prevent users from unintentionally triggering multiple login attempts, which can lead to duplicate requests and session confusion.
-Validate the login session on your server.
Accept only the first valid callback. Your backend should track each login attempt using a unique session identifier or timestamp. Once a callback is successfully processed, mark it as consumed (e.g., loginProcessed = true) and gracefully ignore any subsequent callbacks with the same state or code.
Generate and store a unique state parameter for each login attempt. This ensures that each authentication flow is traceable and prevents replay attacks or accidental reprocessing.
Please refer to Pass custom state in authentication requests (MSAL.js) | Azure Docs
-Use Microsoft Authentication Libraries (MSAL) with proper redirect handling.
Microsoft Authentication Libraries support passing custom state parameters and managing redirects effectively. You can read more at Authentication configuration options - Microsoft Authentication Library for JavaScript | Microsoft …
-If your app supports it, consider switching to popup login, which can help avoid full-page reloads and reduce the likelihood of duplicate submissions.
I hope these suggestions help you build a more resilient authentication flow.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.