microsoft-authentication-library-for-js icon indicating copy to clipboard operation
microsoft-authentication-library-for-js copied to clipboard

Backport hydrateCache() changes to 2.x

Open sameerag opened this issue 1 year ago • 1 comments

For some 1P apps to migrate to 3.x, hydrateCache() functionality is needed for compatibility. The original PR is #6271.

P.S: Some tests are still being fixed

sameerag avatar Apr 24 '24 17:04 sameerag

Guys, whoever is working on this... There is literally 0 documentation available for hydrateCache. Here I am diving through the source code trying to figure out how exactly this is supposed to work.

drmanhatin avatar May 28 '24 22:05 drmanhatin

Guys, whoever is working on this... There is literally 0 documentation available for hydrateCache. Here I am diving through the source code trying to figure out how exactly this is supposed to work.

That is by design. You should assume that undocumented APIs are not intended for public use, as is the case for hydrateCache. loadExternalTokens is the API you should use if you have testing scenarios and that is documented here: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/testing.md

tnorling avatar May 28 '24 23:05 tnorling

Guys, whoever is working on this... There is literally 0 documentation available for hydrateCache. Here I am diving through the source code trying to figure out how exactly this is supposed to work.

That is by design. You should assume that undocumented APIs are not intended for public use, as is the case for hydrateCache. loadExternalTokens is the API you should use if you have testing scenarios and that is documented here: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/testing.md

I do work with loadExternalTokens, but that does not set the active account in session storage, so it was unclear for me how to get msal-browser to properly initialize without using hydrateCache (or setting these entries manually). Trying to follow these steps you've suggested, as the code in the testing sample doesnt work anymore with recent versions of msal-browser.

https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/6739#issuecomment-1854467572

Probably I'm misunderstanding how I'm supposed to work with loadExternalTokens, or using it for the wrong purpose. For your understanding, I am trying to login a user using ROPC for our end to end tests in Playwright.

Btw thanks for the quick reply, and I understand that this is not the right place or channel to provide support on what I am trying to achieve. Just wanted to clarify my usecase, perhaps its valid (probably not).

drmanhatin avatar May 29 '24 08:05 drmanhatin

@drmanhatin Please open an issue with your questions and we can have a more focused discussion about your specific use case

tnorling avatar May 30 '24 21:05 tnorling