Program.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using System.Net.Http;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
  7. using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
  8. using Microsoft.Extensions.DependencyInjection;
  9. namespace Wasm.Authentication.Client
  10. {
  11. public class Program
  12. {
  13. public static async Task Main(string[] args)
  14. {
  15. var builder = WebAssemblyHostBuilder.CreateDefault(args);
  16. builder.Services.AddApiAuthorization<RemoteAppState, OidcAccount>()
  17. .AddAccountClaimsPrincipalFactory<RemoteAppState, OidcAccount, PreferencesUserFactory>();
  18. builder.Services.AddHttpClient<WeatherForecastClient>(client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
  19. .AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
  20. builder.Services.AddSingleton<StateService>();
  21. builder.RootComponents.Add<App>("app");
  22. await builder.Build().RunAsync();
  23. }
  24. }
  25. }