-
Notifications
You must be signed in to change notification settings - Fork 394
Description
Library version used
4.61.1
.NET version
.Net Framework 4.8
Scenario
PublicClient - desktop app
Is this a new or an existing app?
The app is in production, and I have upgraded to a new version of MSAL
Issue description and reproduction steps
This is an attempt to take issue #4681 , as the issue is relevant to us and no further discussion was ongoing in that issue.
MsalCacheHelper.CreateAsync(StorageCreationProperties) does create a folder for the MsalCache, but MsalCacheHelper.RegisterCache(ITokenCache) fails to create the msal-cache file.
If a series of CreateAsync and RegisterCache calls are made, one can observer the msal-cache LOCK file appearing and disappearing, implying creation of some sort.
This issue started appearing ever since we upgraded the Microsoft.Identity.Client.Extensions.Msal library from 2.19.3 to 4.61.1.
Microsoft.Identity.Client was also upgraded from 4.38.0 to 4.61.1. The code has not been altered in any way, only the csproj files.
Prior the upgrades, the cache file was getting created and everything was fine. However, after upgrade the cache file is not getting created and we are getting continuous login popups. The authentication is valid and the request goes through, but for each request we get a popup(since the caching fails).
IPublicClientApplication.GetAccountsAsync continuously returns no accounts since there is no cache file.
It seems like either CreateAsync and RegisterCache fails to do what it does. No exception is thrown so there is little to work with.
Relevant code snippets
string CacheFileName = "msal-cache";
string CacheDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MsalCache");
IMsalHttpClientFactory httpClientFactory = new AuthenticationClientFactory(env);
var pca = PublicClientApplicationBuilder
.Create(env.ClientId)
.WithAuthority(env.Authority)
.WithRedirectUri("some-redirect")
.WithHttpClientFactory(httpClientFactory)
.Build();
var storagePropertiesBuilder =
new StorageCreationPropertiesBuilder(CacheFileName, CacheDir);
StorageCreationProperties storageProperties = storagePropertiesBuilder.Build();
var cacheHelper = await MsalCacheHelper.CreateAsync(storageProperties);
cacheHelper.RegisterCache(pca.UserTokenCache);Expected behavior
A cache-file is created in its designated place.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
2.19.3
Solution and workarounds
No response