This repository contains two projects:
- An ASP.NET Core MVC application integrated with Auth0 authentication in the
catalog
folder. - An ASP.NET Core Web API protected with Auth0 in the
redeem-api
folder.
Check out the article Call Protected APIs in ASP.NET Core for the implementation details.
- .NET 6 SDK installed on your machine
- Visual Studio 2022 (optional)
-
Clone the repo with the following command:
git clone https://github.com/auth0-blog/call-protected-api-aspnet-core.git
-
Move to the
redeem-api
folder. -
Add your Auth0 domain and API identifier to the
appsettings.json
configuration file (see Configure the API for more details). Take note of the API identifier. -
Type
dotnet run
in a terminal window to launch the API. -
Move to the
catalog
folder. -
Add your Auth0 domain, client id, and client secret to the
appsettings.json
configuration file (see Configure the catalog application for more details). Also, Assign the API identifier value to theAudience
key. -
Type
dotnet run
in a new terminal window to launch the application. -
Point your browser to the https://localhost:7095 address. You should see a web page like the following: