Closed coeguru closed 11 months ago
This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @hectormmg please follow up.
This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @hectormmg please follow up.
Hey we are still facing the issue, @hectormmg do you know when will you be able to get to this ?
We are experiencing the same issue where some people in some browsers (firefox & safari) and mobile browsers, after the loginRedirect(); the getAllAccounts call returns an empty array. We however are using:
@azure/msal-angular": "^1.1.2 msal": "^1.4.6
I have also run into this issue
@hectormmg , Any update on this. its been like 2 months since I posted the question. It would be nice to get some light on it.
@coeguru sorry for the delay, I see you shared snippets from a Node sample, have you looked at the add-in sample for msal-browser?
@coeguru sorry for the delay, I see you shared snippets from a Node sample, have you looked at the add-in sample for msal-browser?
The addin sample does not utilize msal.js in any meaningful way if you ask me. It does use msal.js to authenticate the user, but the accesstoken is simply stored in the React state without any way to refresh it again. As such, it does not save the account.
Yeah the sample code even basic compared to the code snippets I mentioned, we ended up caching the token in localStorage and not rely on MSAL to cache.
Even this document mentions us to not rely on the local cache of any library. https://learn.microsoft.com/en-us/office/dev/add-ins/develop/auth-with-office-dialog-api
@hectormmg
I've encountered a similar issue while using the dialog API for login. The local storage of the dialog isn't accessible to the task pane, causing getAllAccounts
to return null upon add-in reload which results in the failure of acquireTokenSilent
. This behavior changed due to recent storage partitioning updates in Chrome and other browsers.
Are there any upcoming plans for @azure/msal-browser to incorporate alternatives for enabling silent login without relying solely on local storage? Considering evolving browser security measures like storage partitioning and third-party cookies phase out.
@coeguru
You mentioned that instead of relying on the library you are storing access tokens within local storage from your code.
how are you managing silent login in case of task pane reload or token expiration similar to @azure/msal-browser library's acquireTokenSilent
method?
@parinda296 , The token has the validity of 1hr. If there a new call to get the token in that one hour, I get it from the localStorage. If the token is expired, I am currently asking the user to login again.
There are 2 ways in which we can get around the token expiry -
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
2.34.0
Wrapper Library
Not Applicable
Wrapper Library Version
None
Public or Confidential Client?
Public
Description
myMSALObject.getAllAccounts()
return empty when logged in viamyMSALObj.loginRedirect(loginRequest);
inside Excel Addin Dialog created usingOffice.context.ui.displayDialogAsync
. Because the getAllAccounts() is empty, we are not able to set the active account for fetching the token silently after the initial authentication.What I see is if I open the dialog as present in the code section. The localStorage is not populated with msal accounts but If I use the
myMSALObj.acquireTokenPopup(request)
the localstorage is populated but I dont want to use the popup as it is blocked in the browsers by default.MSAL Configuration
Relevant Code Snippets
AuthRedicect
These snippets are from https://github.com/OfficeDev/Office-Add-in-samples/tree/main/Samples/auth/Office-Add-in-NodeJS-SSO