Skip to content

Commit

Permalink
NR: Use MSAL Broker on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Jan 21, 2025
1 parent 8be309c commit c99bae3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/NewsReader/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="NLog" Version="5.3.4" />
<PackageVersion Include="Microsoft.Graph" Version="5.68.0" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.67.2" />
<PackageVersion Include="Microsoft.Identity.Client.Desktop" Version="4.67.2" />
<PackageVersion Include="Microsoft.Identity.Client.Broker" Version="4.67.2" />
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.67.2" />
<PackageVersion Include="System.ServiceModel.Syndication" Version="9.0.1" />
<PackageVersion Include="System.Waf.Core" Version="8.0.2-alpha.0.81" />
Expand Down
3 changes: 3 additions & 0 deletions src/NewsReader/NewsReader.Presentation/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public App(ISettingsService settingsService, IAppInfoService appInfoService, Laz

public static string LogFileName { get; } = Path.Combine(FileSystem.CacheDirectory, "Logging", "AppLog.txt");

public static Window? CurrentWindow { get; private set; }

protected override Window CreateWindow(IActivationState? activationState)
{
var window = new Window((Page)appController.MainView)
Expand All @@ -56,6 +58,7 @@ protected override Window CreateWindow(IActivationState? activationState)
window.Stopped += (_, _) => OnStopped();
window.Destroying += (_, _) => OnDestroying();
window.Resumed += (_, _) => OnResumed();
CurrentWindow = window;
return window;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@
<PackageReference Include="Microsoft.Maui.Controls" VersionOverride="$(MauiVersion)" />

<PackageReference Include="Microsoft.Graph" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.Identity.Client.Broker" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
<PackageReference Include="System.ServiceModel.Syndication" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<PackageReference Include="Microsoft.Identity.Client.Desktop" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NewsReader.Applications\NewsReader.Applications.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public WebStorageService()
#elif IOS
builder.WithIosKeychainSecurityGroup(Foundation.NSBundle.MainBundle.BundleIdentifier);
#elif WINDOWS
Microsoft.Identity.Client.Desktop.DesktopExtensions.WithWindowsEmbeddedBrowserSupport(builder);
Microsoft.Identity.Client.Broker.BrokerExtension.WithBroker(builder, new BrokerOptions(BrokerOptions.OperatingSystems.Windows)
{
Title = AppInfo.Name
});
builder.WithParentActivityOrWindow(() => WinRT.Interop.WindowNative.GetWindowHandle(App.CurrentWindow!.Handler.PlatformView!));
#endif
publicClient = builder.Build();
}
Expand Down

0 comments on commit c99bae3

Please sign in to comment.