question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Msal-react seems not to be React 18 compliant

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.28.3

Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version

1.4.7

Public or Confidential Client?

Public

Description

Hi ,

Switching React from 17.0.2 to 18.2.0, the msal authentication process stops now to show an error message on screen when the related app is “called” in the browser. After having the error returned, rewriting the calling URL of the app once again leads finally to the app.

Reverting React to 17’s version is solving the issue.

Thanks in advance for your support

Error Message

on the browser screen, the process stops and shows this error:

Request Id: 53d9342b-7c94-4c98-90a7-447254597200 Correlation Id: c75471e3-954b-4b43-9ac2-a3c9bf75c985 Timestamp: 2022-10-04T15:42:44Z Message: AADSTS50011: The redirect URI ‘http://localhost:3000/#code=0.AS0AYSBbEGm2MUuSrCTTBNGV3LQFRGpvFsRFtDWJEdxBGGYtAMs.AgABAAIAAAD--DLA3VO7QrddgJg7WevrAgDs_wQA9P_wg8k--6oCcOfaxld9i3oEKoJ49KjS0BozT0YBN3a7rFCIZi83kt3v-x5SeOgSS3PQyjHL6sOdDF5mDprdNAjdj_Ur8hWwVkXfRqYS6rMhQQBcLz3qAegGiAdHHV3JZ4cs5hsHCd9DAAlSSWl55toJ0ampg3WbbAM32CnSfz1WNDXSGReMph1OErRafwc4gmNdOgZ01OaJyDmln8G2FCg9-oB_0dBiL7jBF1ADXCcKh1nDkOcRV0-wkYSEKaWiZ5GAIFBJ7sWWC2kWh45U_FIZYeHqag3SLCgnihSot9RMZH2s5EBZcBUlA49YM4x9_J8J-yqMxBNHsUPMeHWFrDqUyq19lU55nJPWqkK2w8J887-fzhgaExR3cvCf_5yM0EXCcaYce9tLFSY9FLjOHfdlkqfplS8fiY3UFluzRtJA8W0k6K4i-FY1WRZFEFy9aDjUIec1mE6pBwQWKm8xucIRth2gbeDISOM21C5DF7KDO-q9njcqtPxzQGHJMmW1mNRQVFxKeewy3iWSyMjgBNk9SeqraYDCqLJ_uuDbWOcWW4-Dnwg84j9WCpP64zjMxRzEDdxumiyvjiHL6xc9J1tcjcAYDl1B9SKTUwO8um4eWpngjV7c6sAlOkQG8odQIfm7F40dqMWoWveLD4QD2l_EV-ljGQ3Jo-7VmgAIISh6YPyqS9C5JQp5WcHkQ2YPsHbou_KmyTX1i6INhXS6E8octBLD_fGBjk3uOjqKH4zgj13dno5FP4xpYZcuMFV-_xMROZY91y6ui_y5Jxthy3QUpKVRBQxv5ih218i7NPUgk5TmA0apQt_xptkw8IT4Qlg7TIhSRE6pyGGF-d8Lhsw0Xzg4-6VnRZfouVy4wy2SYropz8xMZ2dOEOJkMj0Y_89ounjUvputAeH8DuuHtGNK6JaJTO6D2beG65bJJ8kiCtY1Ent0Jz0mvyMDPrCFDH6el3POfwdq59M_ZtaCdHQDQq6IMJypRA&client_info=eyJ1aWQiOiJlYWFjZTBkZC1kMDhjLTQwZmEtYTdiNC05ODhmNTllYjlmMGIiLCJ1dGlkIjoiMTA1YjIwNjEtYjY2OS00YjMxLTkyYWMtMjRkMzA0ZDE5NWRjIn0&state=eyJpZCI6ImFlMmVhYjRjLWNhMGQtNDVlOS05YWM3LTEwODYwY2E3NmE0MCIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0%3D&session_state=76e6846a-6d8c-4841-93bc-8d169f04688a’ specified in the request does not match the redirect URIs configured for the application ‘6a4405b4-166f-45c4-b435-8911dc411866’. Make sure the redirect URI sent in the request matches one added to your application in the Azure portal. Navigate to https://aka.ms/redirectUriMismatchError to learn more about how to fix this.

Msal Logs

no msal logs returned at this step.

MSAL Configuration

N/A

Relevant Code Snippets

N/A

Reproduction Steps

  • switch React from 17 to 18 version
  • npm install
  • npm start
  • launch the app

Expected Behavior

The authentication may not stop and lead to the app.

Identity Provider

Azure B2C Basic Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Internet Explorer

Regression

react 17.0.2

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
jo-arroyocommented, Oct 5, 2022

@vherilier We haven’t seen this issue with our React apps running on React 18. Are you able to provide your configuration and usage above? Specifically, where you are providing the redirectUri. Any logs or network traces you are providing could be useful as well.

0reactions
vheriliercommented, Oct 12, 2022

@tnorling providing explicitly redirect URIs solves the issue. Adding progression control to loginRedirect execution in Azure file seems to reduce calls when the application starts.

Thanks for double checking the code and for your suggestions. I think the issue is over and you can close it. Thanks and regards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React 18 Support and Issues #4341 - GitHub
MSAL React (@azure/msal-react) ... As React 18 RC is released I think it would be nice to have ... Seems the issue has...
Read more >
Redirect onLoad only if not authenticated with @azure/msal ...
Ok, I was able to sort this out with some help: const App = () => { const isAuthenticated = useIsAuthenticated(); const {...
Read more >
How to Upgrade to React 18
If your app doesn't work after upgrading, check whether it's wrapped in <StrictMode> . Strict Mode has gotten stricter in React 18, and...
Read more >
@azure/msal-react - npm
The MSAL library for JavaScript enables client-side JavaScript applications to authenticate users using Azure AD work and school accounts (AAD), ...
Read more >
React msal - Veiled Mirror
Is there is any solutions to make the user authenticated to msal/react ... Sep 18, 2020 · (create-react-app) Install the required client-side libraries....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found