diff --git a/EmbeddedMsalCustomWebUi.Wpf/EmbeddedMsalCustomWebUi.Wpf.csproj b/EmbeddedMsalCustomWebUi.Wpf/EmbeddedMsalCustomWebUi.Wpf.csproj index ef822e9..324fd56 100644 --- a/EmbeddedMsalCustomWebUi.Wpf/EmbeddedMsalCustomWebUi.Wpf.csproj +++ b/EmbeddedMsalCustomWebUi.Wpf/EmbeddedMsalCustomWebUi.Wpf.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0-windows;net6.0-windows true enable 1.0.3 @@ -29,7 +29,8 @@ - + + diff --git a/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml b/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml index 7e5dacd..00e2e7a 100644 --- a/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml +++ b/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml @@ -1,16 +1,18 @@ - + - + diff --git a/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml.cs b/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml.cs index 1bff362..a362106 100644 --- a/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml.cs +++ b/EmbeddedMsalCustomWebUi.Wpf/Internal/EmbeddedWebUiWindow.xaml.cs @@ -1,15 +1,14 @@ -using Microsoft.Identity.Client.Extensibility; +using Microsoft.Identity.Client; using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Web; using System.Windows; -using System.Windows.Navigation; namespace EmbeddedMsalCustomWebUi.Wpf.Internal { - public partial class EmbeddedWebUiWindow : Window + internal partial class EmbeddedWebUiWindow : Window { private readonly Uri _authorizationUri; private readonly Uri _redirectUri; @@ -30,26 +29,27 @@ public EmbeddedWebUiWindow( _cancellationToken = cancellationToken; } - private void WebBrowser_Navigating(object sender, NavigatingCancelEventArgs e) + private void webView2_NavigationStarting(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e) { - if (!e.Uri.ToString().StartsWith(_redirectUri.ToString())) + if (!e.Uri.StartsWith(_redirectUri.ToString())) { // not redirect uri case return; } // parse query string - var query = HttpUtility.ParseQueryString(e.Uri.Query); + var uri = new Uri(e.Uri); + var query = HttpUtility.ParseQueryString(uri.Query); if (query.AllKeys.Any(x => x == "code")) { // It has a code parameter. - _taskCompletionSource.SetResult(e.Uri); + _taskCompletionSource.SetResult(uri); } else { // error. _taskCompletionSource.SetException( - new MsalExtensionException( + new MsalException( $"An error occurred, error: {query.Get("error")}, error_description: {query.Get("error_description")}")); } @@ -60,7 +60,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { _token = _cancellationToken.Register(() => _taskCompletionSource.SetCanceled()); // navigating to an uri that is entry point to authorization flow. - webBrowser.Navigate(_authorizationUri); + webView2.Source = _authorizationUri; } private void Window_Closed(object sender, EventArgs e) diff --git a/TestApp/App.xaml b/TestApp/App.xaml index ae4276d..ea9f7fa 100644 --- a/TestApp/App.xaml +++ b/TestApp/App.xaml @@ -1,10 +1,9 @@ - - - - + + diff --git a/TestApp/TestApp.csproj b/TestApp/TestApp.csproj index 1b948fa..8cec3cf 100644 --- a/TestApp/TestApp.csproj +++ b/TestApp/TestApp.csproj @@ -1,17 +1,17 @@ - + WinExe - netcoreapp3.1 + net6.0-windows true d8844bb0-5042-4342-bccb-764af93cdece false - - - + + +