[Bug] WebView2-based embedded browser does not work in protected directories
See original GitHub issueWhich Version of MSAL are you using ? MSAL 4.28.2
Platform net5-windows10.0.17763.0
What authentication flow has the issue?
- Desktop / Mobile
- Interactive
Is this a new or existing app? This is an existing app attempting to adopt new feature.
Repro
- Install the “evergreen” WebView2 runtime
- Create a .NET 5 console app with the following code
var pca = PublicClientApplicationBuilder.Create(clientId).Build();
var result = await pca.AcquireTokenInteractive(scopes)
.WithUseEmbeddedWebView(true)
.ExecuteAsync();
dotnet publish -r win-x86
the application and copy the publish output in to a directory like%ProgramFiles%
(one that requires admin permission to create a new folder).- Run the console app from the new location.
Expected behavior An embedded WebView2-based browser window appears asking for sign-in.
Actual behavior An empty WinForms dialog appears. There are no errors.
Possible Solution Set the WebView2 runtime environment to point the user data folder outside of the protected directory. https://docs.microsoft.com/en-gb/microsoft-edge/webview2/concepts/userdatafolder
Additional context/ Logs / Screenshots The folder the WebView2 runtime tries to create a user data directory, for the browser profile information (cookies, etc). Moving the executable outside of a protected directory (where non-admin users have write and modify permissions) allows the WebView2 runtime to work.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (11 by maintainers)
Top GitHub Comments
Also, we’ve discussed with the WebView2 SDK folks and they are actively working on a solution “out of the box”. So in MSAL 4.30 we will be setting the UserFolder out of program files and when WebView2 SDK finish up their work (no ETA, but work is in progress), we would upgrade as well.
This is included in MSAL 4.30.0 release.
cc: @mjcheetham @sakkumarfirstam @luismiguelsanchezGL @FreddyD-GH