Closed MannusEtten closed 2 years ago
Hey,
First of all, my sincere apologies for the delayed response.
There is no timeline of such an SDK at the moment, implementing .NET 5 should be possible if you follow what is mentioned in https://community.auth0.com/t/howto-use-the-auth0-oidcclient-winforms-sdk-with-edge-chromium-webview2/57746.
Having this functionality built-in would be a nice to have, but shouldn't be blocking you from using it in the way that is being mentioned. For that reason there is no timeline, but I am more than happy to look at a PR that implements this in the SDK itself.
@frederikprijck just as an FYI, in the VS2022 preview just referencing the old package will cause a build to fail. So the work around's days are numbered. I will try to get some time to look at what's involved in updating for .net 5 and beyond -- I think with the changes (especially coming in .net 6) you might be able to combine wpf, winforms, & uwp packages into a "windows" package.
@frederikprijck - Since the WebView2 implementation may be considered a breaking change, I only created a draft PR with my implementation. I want to follow the guideline of discussing before submitting a PR.
The reason why I would consider this a breaking change is that it imposes the requirement of the WebView2 runtime to be installed on the user machine, which was not a requirement previously.
Having this functionality built-in would be a nice to have, but shouldn't be blocking you from using it in the way that is being mentioned. For that reason there is no timeline, but I am more than happy to look at a PR that implements this in the SDK itself.
This issue is now blocking me from updating to .Net 6. In Visual Studio 2022, this causes a compile time error in projects targeting .Net 5+
I looked into this and I was able to successfully migrate our WPF QuickStart sample to use .NET6 (https://github.com/auth0-samples/auth0-WinFormsWPF-oidc-samples/commit/1fbcd876fb603a812a2d0a4fde692d99f1d4210a).
The steps I had to take where:
.csproj
file and the project's dependencies.Microsoft.Windows.CsWinRT
to get rid of the following error Microsoft.Toolkit.Wpf.UI.Controls.WebView.dll cannot be referenced because it uses built-in support for WinRT, which is no longer supported in .NET 5 and higher. An updated version of the component supporting .NET 5 is needed.
Microsoft.Web.WebView2
WebViewBrowser
implementation that supports .NET6: https://github.com/auth0-samples/auth0-WinFormsWPF-oidc-samples/commit/1fbcd876fb603a812a2d0a4fde692d99f1d4210a#diff-de10b23b78c263497cbf3a8f065f7ae7d9987a72355011924d2fc2c523c7cd5d and ensure to set it when configuring our SDK.Doing all of the above ensured I could run our Quickstart Example application using .NET6. Even though I understand this isn't ideal, it doesn't seem to be blocking.
Closing this for now, can always reopen if needed.
thanks for the nice work, unfortunately, because of the lack of support when i opened the ticket I moved on and replaced the library with another solution. Maybe I will return to use it again because the concept was really good for me. So I will dive into later again.
@MannusEtten @frederikprijck Thanks for raising this and putting together a sample for other users... I've cleaned up the implementation a little for future developers developing WPF in 2022 on .NET 6 lol.
Rather than deal with the headache of Auth0.OidcClient.WPF 3.2.x
and all of the incompatibilities that are in there from referencing the now removed WinRT APIs like the Microsoft.Toolkit.Wpf.UI.Controls incompatible with .Net 5.0
error that I was getting.
I would recommend simply NOT using the Auth0.OidcClient.WPF
package at all and instead use the Auth0.OidcClient.Core
package and implement the Auth0Client
yourself.
This way you don't need to add in all the compatibility libraries such as Microsoft.Windows.CsWinRT
, or set a windows target version if you don't want to. Mine's still targeting net6.0-windows
.
Recommended Nuget Packages
<ItemGroup>
<PackageReference Include="Auth0.OidcClient.Core" Version="3.2.4" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1150.38" />
</ItemGroup>
Auth0Client.cs
namespace Auth0.OidcClient
{
/// <summary>
/// Primary class for performing authentication and authorization operations with Auth0 using the
/// underlying <see cref="IdentityModel.OidcClient.OidcClient"/>.
/// </summary>
public class Auth0Client : Auth0ClientBase
{
/// <summary>
/// Creates a new instance of the Auth0 OIDC Client.
/// </summary>
/// <param name="options">The <see cref="Auth0ClientOptions"/> specifying the configuration for the Auth0 OIDC Client.</param>
public Auth0Client(Auth0ClientOptions options)
: base(options, "wpf")
{
options.Browser = options.Browser ?? new WebViewBrowser();
}
}
}
Supported WebView2 Browser Implementation WebViewBrowser.cs
Basic Implementation and usage MainWindow.xaml.cs
Again thanks heaps for the example @frederikprijck was a life saver!
Thanks for @kt-dm, thats a very helpful post for anyone experiencing issues with our SDK in any platform, as the issue goes way beyond WPF.
As you correctly notice, most of the code is in our Core package. Platform specific code is in the Platform specific packages, which typically isn't that much code. So the approach you are mentioning shouldn't be too complicated in situations where it's needed.
when can we expect a wpf library which is not dependend on .net framework components like the WebView?
what is the suggested way now to show the login prompt for a .net5-wpf app?