0

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);
  • I think the issue may have to do with permissions of wpf exe, see answers to these links https://stackoverflow.com/questions/6733888/wpf-clickonce-and-partial-trust-problem https://learn.microsoft.com/en-us/dotnet/desktop/wpf/security-wpf?view=netframeworkdesktop-4.8&viewFallbackFrom=netdesktop-5.0 – mzm Dec 26 '22 at 23:42

0 Answers0