This repo contains the source code for the
blog post
where I explained how to encapsulate the action of getting access tokens
from IdentityServer (or any token service) by using the HttpClientFactory
and HttpMessageHandler
.
The sample is composed of 3 ASP.NET services:
- IdentityServer
- Consumer API
- Protected API
How they talk to each other is explained in the blog post. In a nutshell, the Consumer API exposes endpoints that returns data obtained from the Protected API. The Consumer API obtains access tokens from IdentityServer and uses it to retrieves "confidential" information from the Protected API.
- Run
docker-compose up
from the root to start all apps. - Send a request to the
Consumer API
on:http://localhost:5006/api/consumer/version3
- Optionally, you can try
version1
andversion2
. The results are the same, but the code is different. See blog post for more info.
- Docker/Compose
- .NET 6 SDK (if you want to build/debug locally)