You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrap long Markdown lines in access token management docs
Split long lines into shorter ones to enhance readability and maintain consistency across the documentation. This change does not alter the content but improves formatting for easier collaboration and review.
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/web-apps.md
+21-10Lines changed: 21 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,8 @@ redirect_from:
9
9
- /foss/accesstokenmanagement/web_apps/
10
10
---
11
11
12
-
The `Duende.AccessTokenManagement` library automates all the tasks around access token lifetime management for user-centric web applications.
12
+
The `Duende.AccessTokenManagement` library automates all the tasks around access token lifetime management for
13
+
user-centric web applications.
13
14
14
15
To use this library, start by adding the library to your .NET projects.
15
16
@@ -21,14 +22,16 @@ While many of the details can be customized, by default the following is assumed
21
22
22
23
* ASP.NET Core web application
23
24
* cookie authentication handler for session management
24
-
* OpenID Connect authentication handler for authentication and access token requests against an OpenID Connect compliant token service
25
+
* OpenID Connect authentication handler for authentication and access token requests against an OpenID Connect compliant
26
+
token service
25
27
* the token service returns a refresh token
26
28
27
29
## Setup
28
30
29
-
30
-
31
-
By default, the token management library will use the ASP.NET Core default authentication scheme for token storage (this is typically the cookie handler and its authentication session), and the default challenge scheme for deriving token client configuration for refreshing tokens or requesting client credential tokens (this is typically the OpenID Connect handler pointing to your trusted authority).
31
+
By default, the token management library will use the ASP.NET Core default authentication scheme for token storage (this
32
+
is typically the cookie handler and its authentication session), and the default challenge scheme for deriving token
33
+
client configuration for refreshing tokens or requesting client credential tokens (this is typically the OpenID Connect
Similar to the worker service support, you can register HTTP clients that automatically send the access token of the current user when making API calls. The message handler plumbing associated with those HTTP clients will try to make sure, the access token is always valid and not expired.
95
+
Similar to the worker service support, you can register HTTP clients that automatically send the access token of the
96
+
current user when making API calls. The message handler plumbing associated with those HTTP clients will try to make
97
+
sure, the access token is always valid and not expired.
Of course, the ASP.NET Core web application host could also do machine to machine API calls that are independent of a user. In this case all the token client configuration can be inferred from the OpenID Connect handler configuration. The following registers an HTTP client that uses a client credentials token for outgoing calls:
118
+
Of course, the ASP.NET Core web application host could also do machine to machine API calls that are independent of a
119
+
user. In this case all the token client configuration can be inferred from the OpenID Connect handler configuration. The
120
+
following registers an HTTP client that uses a client credentials token for outgoing calls:
114
121
115
122
```csharp
116
123
// registers HTTP client that uses the managed client access token
@@ -170,8 +177,10 @@ public class HomeController : Controller
170
177
171
178
There are three extension methods on the HTTP context that simplify interaction with the token management service:
172
179
173
-
*`GetUserAccessTokenAsync` - returns an access token representing the user. If the current access token is expired, it will be refreshed.
174
-
*`GetClientAccessTokenAsync` - returns an access token representing the client. If the current access token is expired, a new one will be requested
180
+
*`GetUserAccessTokenAsync` - returns an access token representing the user. If the current access token is expired, it
181
+
will be refreshed.
182
+
*`GetClientAccessTokenAsync` - returns an access token representing the client. If the current access token is expired,
183
+
a new one will be requested
175
184
*`RevokeRefreshTokenAsync` - revokes the refresh token
176
185
177
186
```csharp
@@ -189,7 +198,9 @@ public async Task<IActionResult> CallApi()
189
198
190
199
### HTTP Client Factory
191
200
192
-
Last but not least, if you registered clients with the factory, you can use them. They will try to make sure that a current access token is always sent along. If that is not possible, ultimately a 401 will be returned to the calling code.
201
+
Last but not least, if you registered clients with the factory, you can use them. They will try to make sure that a
202
+
current access token is always sent along. If that is not possible, ultimately a 401 will be returned to the calling
0 commit comments