React Web App - reset password B2C not working with MsalAuthenticationTemplate
See original GitHub issueLibrary
- [@azure/msal-browser@2.12.0]
msal@1.x.x
or@azure/msal@1.x.x
- [@azure/msal-react@1.0.0-beta.0]
@azure/msal-react@1.x.x
Description
We are currently using this library to implement the Azure B2C reset password flow in our react app. We downloaded the sample here, changed the config so it is using our B2C tenant and it worked; we were able to reset our password and we become authenticated.
However, when we start using MsalAuthenticationTemplate
we run into problems. We are using MsalAuthenticationTemplate
to force the user to sign in if they are unauthenticated. I can go through the reset password flow until the end, where
I receive multiple failed bad requests on https://<tenant>.b2clogin.com/<tenant>.onmicrosoft.com/<signinuserflow>/oauth2/v2.0/token
Here is the code:
const SecureContent = (props) => {
const { instance } = useMsal();
useEffect(() => {
const callbackId = instance.addEventCallback((event) => {
if (event.eventType === "msal:loginFailure") {
if (
event.error &&
event.error.errorMessage.indexOf(b2cErrorCodes.FORGOTTEN_PASSWORD) >
-1
) {
instance.loginRedirect({
authority:
"https://<tenant>.b2clogin.com/tfp/<tenant>.onmicrosoft.com/<resetPasswordAuthority>",
}).then(() => {
});
}
}
});
return () => {
if (callbackId) {
instance.removeEventCallback(callbackId);
}
};
}, []);
return props.children;
};
const WebSecurityContainer = (props) => {
const pca = new PublicClientApplication(ourConfiguration);
return (
<MsalProvider instance={pca}>
<SecureContent>
<MsalAuthenticationTemplate
interactionType={InteractionType.Redirect}
authenticationRequest={scopes: [
"https://<tenant>.onmicrosoft.com/<clientId>/authentication",
]}>
{props.children}
</MsalAuthenticationTemplate>
</SecureContent>
</MsalProvider>
);
};
Any ideas on what I am doing wrong? If you need more info around the configuration then let me know.
Source
- Internal (Microsoft)
- Customer request
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Password Reset issue with MSAL React SPA #274 - GitHub
I'm wondering if anyone else has observed issues like this, using the MS provided Password Reset instructions. Thank you!
Read more >Tutorial: Create a React single-page app that uses auth code ...
In this tutorial, you create a React SPA that can sign in users and use the auth code flow to obtain an access...
Read more >How do I make 'forgot password' working in react-aad-msal ...
Using msal-react and msal-browser I was able to get the Azure AD B2C password reset page to appear using the following code (assuming...
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 >How to call an AAD protected Azure Function from React
How to call an AAD protected Azure Function from React · Step 1: Create React App · Step 2: Create an App Registration...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes you should be able to do something like this:
@AshTappin This is by design.