I have a WPF application that uses the Microsoft.Identity.Client package to authenticate users using Azure AD B2C. This works well on Development, but when I distribute my application with the Setup Project, my application is installed on the Program Files
directory, which is a read-only directory. I assume that MSAL writes tokens or cache files to the directory the exe
is running; so, when the application is initialized without admin privileges, the app cannot write to the directory, and therefore cannot authenticate users.
I've initialized an instance of IPublicClientApplication
within the OnLaunched
method like this:
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId)
.WithB2CAuthority(AuthoritySignUpSignIn)
.WithRedirectUri(RedirectUri)
.Build();
TokenCacheHelper.Bind(PublicClientApp.UserTokenCache);