-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Cannot use .WithUseEmbeddedWebView
on net6-windows
TFW
#3206
Comments
You need to use |
Thanks @bgavrilMS ! That did the trick. I've never had to add an OS version string to my TFW before. It's unintuitive. Is there any plan to make things work with the regular Although now I'm just getting a blank window instead of the regular AzureAD login prompt: |
I've tried the suggested solution but I've got to the same point as @A9G-Data-Droid . The only thing I can see more is that I logged an Exception after the
I'm using |
Maybe this issue is not closed. I haven't been able to test the GUI window. I have been getting the token from the OS. The GUI will need to pop when the token expires. |
My main issue is that I could use the system browser, but if I fail to authenticate, or even just close the browser, the authentication process hangs without giving me any error, while the embedded view returns an exception that I can handle (like it did on .net framework 4.7.2). |
The issue seems to be here: Line 236 in 001a6b3
because CoreWebView2 is null. The WebView2 docs states that settings the I'll try to see if using that fixes the problem. |
The recommendation is to use WAM, not embedded browser. Please see https://aka.ms/msal-net-wam |
But still, we need to fix this null reference exception. If WebView2 cannot be initialized, we should fallback to WV1. Or remove WV2 support completely. |
Since we do not expose WebView2 directly to customers, I propose we remove it completely. WebView1 is more stable as a fallback login mechanism, and WAM is the primary focus. |
Proposal: Let's drop WebView2 and move it to a sample instead. It has this problem and also the device ID doesn't seem to get injected correctly by WAM into it. WebView1 seems to work better in satisfying the "Device is managed" CA policy. |
I'm confused. The official Microsoft recommendation is to stop using WebView and begin using WebView2. Don't you work for Microsoft? FROM: https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/webview
|
@A9G-Data-Droid - I'm not advising you to use WebView1, I'm advising you to use WAM https://aka.ms/msal-net-wam which provides better security and has fewer such issues. Feel free to use WebView2 in your own projects, the API is much better and HTML support are much better than WebView1. |
MSAL now uses WebView1 for AAD authority, but continues to use WebView2 for B2C. For the null ref exception, this would happen if WebView2 isn't initialized properly (by MSAL). Are you using it from a console app, a WinForms app or a WPF app? Are you calling AcquireTokenInteractive from UI thread or from background thread? |
I’m using it from a NET 6 WinForms app.
I was calling it by a UI Thread, in Winforms control events.
I’ve now transitioned to using WAM and it works better than before!
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Bogdan ***@***.***>
Sent: 15 April 2022 12:24
To: ***@***.***>
Cc: Alessandro ***@***.***>; ***@***.***>
Subject: Re: [AzureAD/microsoft-authentication-library-for-dotnet] [Bug] Cannot use `.WithUseEmbeddedWebView` on `net6-windows` TFW (Issue #3206)
MSAL now uses WebView1 for AAD authority, but continues to use WebView2 for B2C.
For the null ref exception, this would happen if WebView2 isn't initialized properly (by MSAL). Are you using it from a console app, a WinForms app or a WPF app? Are you calling AcquireTokenInteractive from UI thread or from background thread?
—
Reply to this email directly, view it on GitHub<#3206 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACG7N5JCWO5VAW2VU6WQFTVFE7UNANCNFSM5P4C65MQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Thanks @bgavrilMS |
Yes, I think it's like a console app, i.e. there is no UI thread. |
Please target net6-windows10.0.177763.0 to get embedded webview by default. Otherwise, for a pure net6 app, add a reference to Microsoft.identity.Client.Desktop package and add |
@bgavrilMS I just tested adding
|
@A9G-Data-Droid - my bad- please edit your .csproj file and change the target framework from |
Ok, that is working. My question remains about |
Ah, it's not an random number, it represents a version of the Windows SDK. We won't introduce breaking changes.
But we are actually planning to stop calling WIndows SDK and rely only on |
Does that cause a problem for you @rtheil-growlink ? MSAL is in the business of popping up webviews... |
Sorry, maybe I was not clear? Could not get WebView2 to be utilized when trying to use Microsoft auth. Changing OS target solved the issue and allowed the WebView2 dependency to show up as part of Microsoft.Identity.Client, and allowing the in-app popup for MSA. |
Which version of MSAL.NET are you using?
MSAL.NET 4.42.0.0
Platform
net6-windows
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.1.0
Windows 10 Pro 21H1 19043.1526
What authentication flow has the issue?
Other?
Is this a new or existing app?
c. This is a new app or experiment.
Repro
Expected behavior
I would expect the embedded login prompt to pop up.
Actual behavior
I get an unhandled
Microsoft.Identity.Client.MsalClientException
details below.Possible solution
The error says that this feature is supported in
net5-windows10.0.17763.0
so I would expect this same feature to exist innet6-windows
Additional context / logs / screenshots / links to code
The text was updated successfully, but these errors were encountered: