...

/

Call the Protected API

Call the Protected API

Learn to call the protected API from the Blazor WebAssembly application.

In this lesson, we are going to enable the Blazor WebAssembly application to make authorized requests to the weather forecast API.

Create the HTTP client

To make our HTTP request to the API, we need an HTTP client. Fortunately, the .NET platform provides a powerful client.

Let’s move to the Client folder of our solution and install the HTTP client by running the following command:

dotnet add package Microsoft.Extensions.Http

This package allows us to create named HTTP clients and customize their behavior.

We need to make authorized requests to the weather forecast API. This means that the requests must include an access token issued by Auth0.

We create an HTTP client that automatically attaches an ...