What is Blazor? A Tutorial on Building Web Apps with Authentication

Just two notes from when I was adding these helpful code bits to my project that may help others:

  • If you’re just going to connect from the wasm to the host, extend BaseAddressAuthorizationMessageHandler instead of AuthorizationMessageHandler. It sets the URL for you so you don’t need the ConfigureHandler() call.

  • You need to put your MessageHandler into the services, e.g.

          builder.Services.AddScoped<Auth0MessageHandler>();
    
          builder.Services.AddHttpClient("ServerAPI", client => 
              client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
                  .AddHttpMessageHandler<Auth0MessageHandler>();
2 Likes

Thanks for sharing that @zgrose!

Thanks for your contribution @zgrose!