Skip to content

Commit ab5554b

Browse files
authored
Merge pull request #676 from DuendeSoftware/mb/atmdocs
Update AccessTokenManagement docs in IdentityServer area
2 parents eb36220 + 3b55b0a commit ab5554b

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/content/docs/identityserver/tokens/requesting.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Pragma: no-cache
5050
```
5151

5252
### .NET Client Library
53-
In .NET you can leverage the [IdentityModel](https://identitymodel.readthedocs.io/en/latest/) client library to [request](https://identitymodel.readthedocs.io/en/latest/client/token.html) tokens.
53+
In .NET you can use the [Duende IdentityModel](../../../identitymodel) client library to [request](../../../identitymodel/endpoints/token) tokens.
5454

5555
The above token request would look like this in C#:
5656

@@ -72,36 +72,37 @@ var response = await client.RequestClientCredentialsTokenAsync(new ClientCredent
7272
### Automating Token Requests In ASP.NET Core And Worker Applications
7373

7474
The [Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki) library can automate client credential request and token lifetime management for you.
75+
Using this library, you can enable access token management for an HTTP client provided by `IHttpClientFactory`.
7576

76-
Using this library, you only need to register the token client in DI:
77+
You can add the necessary services to ASP.NET Core's service provider by calling `AddClientCredentialsTokenManagement()`. One or more named client definitions need to be registered by calling `AddClient()`.
7778

7879
```cs
7980
// Program.cs
80-
builder.Services.AddAccessTokenManagement(options =>
81-
{
82-
options.Client.Clients.Add("client", new ClientCredentialsTokenRequest
81+
builder.Services.AddClientCredentialsTokenManagement()
82+
.AddClient("client", client =>
8383
{
84-
Address = "https://demo.duendesoftware.com/connect/token",
85-
ClientId = "m2m",
86-
ClientSecret = "secret",
87-
Scope = "api"
84+
client.TokenEndpoint = "https://demo.duendesoftware.com/connect/token";
85+
86+
client.ClientId = "m2m";
87+
client.ClientSecret = "secret";
88+
client.Scope = "api";
8889
});
89-
});
9090
```
9191

92-
You can then add token management to an HTTP-factory provided client:
92+
You can then register named HTTP clients with `IHttpClientFactory`. These named clients will automatically use the above client definitions to request and use access tokens.
9393

9494
```cs
9595
// Program.cs
96-
builder.Services.AddClientAccessTokenClient("client", configureClient: client =>
96+
builder.Services.AddClientAccessTokenHttpClient("client", configureClient: client =>
9797
{
9898
client.BaseAddress = new Uri("https://demo.duendesoftware.com/api/");
9999
});
100100
```
101101

102-
...and finally use the client with automatic token management in your application code:
102+
In your application code, you can then use the named HTTP client with automatic token management to call the API:
103103

104104
```cs
105+
// DataController.cs
105106
public class DataController : Controller
106107
{
107108
IHttpClientFactory _factory;

0 commit comments

Comments
 (0)