MSAL login throws authorization_code_missing_from_server_response 8 out of 10 times

Lydia Edward 10 Reputation points
2025-01-29T00:59:26.6866667+00:00

I have implemented login using MSAL (msal-browser) in my outlook add-in. 8 out of 10 times it fails with the following error. I have implemented a retry logic which still results in this error most times. I cannot find relevant documentation about this error code. Please advise on how to fix this.

msal-browser version - 3.21.0

ClientAuthError: authorization_code_missing_from_server_response: Server response does not contain an authorization code to proceed

***at Ct (msal-browser.min.js:7:5389)***

***at Jn.handleFragmentResponse (msal-browser.min.js:59:1419)***

***at Hs.handleCodeResponse (msal-browser.min.js:69:96211)***

***at xs.acquireTokenPopupAsyncHelper (msal-browser.min.js:69:102027)***

***at async xs.acquireTokenPopupAsync (msal-browser.min.js:69:99829)***
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhil Nasalwai - MSFT 1,685 Reputation points Microsoft External Staff
    2025-01-29T06:14:32.1833333+00:00

    Hello Lydia Edward,

    Thank you for reaching out to Microsoft!!

    For the error - authorization code missing from server response, please find the below work arounds which might help resolve the issue:

    Ensure that the redirect URI used in your application matches the one registered in the Azure Portal for your app registration. Mismatched URIs can cause this error.

    Double check the authorization endpoint URL to ensure it is correct and properly configured.

    Add logging to capture the full server response and inspect it for any missing parameters.

    Ensure the code flow is correctly implemented and that the necessary parameters are being passed correctly.

    Please find the relevant documentation about this error code below:

    Link: Error handling while working with MSAL.js

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.