-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-authentication is required when reloading page using MSAL Angular 4.0.2 and Angular 19.1 #7533
Comments
I'm also having the same issue. |
@gsadrija is this behavior happening every time you reload or just after the first time since upgrading the library? The cache is expected to be invalidated when the user first uses the app with the new version of MSAL. |
@gsadrija can you please also share Trace level logs as described in the issue template? |
Hi @hectormmg, it happens every time I refresh the page. I attached the logs below but please take a look at me AuthService first:
Looking at the console, there first was an error saying that Then I fixed that by adding a null check for After fixing this too with a null check, I still have to re-authenticate every time I refresh the page with the "Select Account" page. I hope this helps. Application logs MSAL Log (refreshed once) |
The issue is that your application is invoking the interceptor before MSAL initialization is complete thus resulting in an interaction_required error. You should make use of the inProgress observable to hold off on making any and all API calls until inProgress is None to ensure MSAL has successfully completed decryption and import of the entries in localStorage. |
Please refer to my AuthService above. I'm doing just that. I didn't change this code at all before upgrading and it worked before. Or am I missing something? |
For me MSAL 4.x completely broke authentication, went back to 3.x for it to work again. |
The AuthService does not show where your API calls, that will invoke the interceptor, are being made. The logs you shared show the interceptor is invoked before initialize, tracking down where this is happening will help you debug this. It may have worked in v3 because the cache did not need to be decrypted and thus this race didn't present an issue, but it was still incorrect usage regardless. @alexanderzeillinger Please open a new issue with your specific blockers so we can help you get back up and running with v4. |
I can confirm - in my case I was calling |
Is there any working example of this showing how it should be implemented when using no login display? In our case, the user is redirected to authenticate if no account is logged in. I'm not able to get it to work even with the standalone sample provided here on GitHub. |
for me this helped:
setting |
Apparently my issue is that I'm loading local language data into my app before the interaction is complete. But then, why doesn't the
take care of that? Also, even when using |
The same problem here |
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
4.0.2
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
4.0-2
Public or Confidential Client?
Public
Description
Hi there,
I did an upgrade to v4 of MSAL angular after upgrading to Angular 19.1.
After the upgrade, I now have to re-authenticate every time I reload the page, even though the cache location in my msalConfig is set to LocalStorage.
I know that there is a behavioural change as seen in:
https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/v3-migration.md
However, there should be no effect when just reloading the page.
Error Message
No response
MSAL Logs
No response
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
Reloading the page should not require the user the authenticate again when using LocalStorage as cacheLocation.
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome
Regression
@azure/msal-angular: 3.1.0
The text was updated successfully, but these errors were encountered: