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
Copy file name to clipboardExpand all lines: src/content/docs/accesstokenmanagement/web-apps.md
+86-56Lines changed: 86 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,15 +20,16 @@ While many of the details can be customized, by default the following is assumed
20
20
token service
21
21
* the token service returns a refresh token
22
22
23
+
Using this library, you can either request `user access tokens` or `client credentials tokens`. User access tokens typically contain information about the currently logged in user, such as the `sub` claim. They are used to access services under the credentials of the currently logged in user. `Client credentials tokens` do not contain information about the currently logged in user and are typically used to do machine-to-machine calls.
24
+
23
25
## Usage
24
26
First, you'll need to add `Duende.AccessTokenManagement.OpenIdConnect` to your solution.
25
27
26
-
Then, there are two fundamental ways to interact with token management:
28
+
Then, there are two fundamental ways to interact with token management:
27
29
1.**Automatic** <Badgetext="recommended"/>: You request a http client from the IHTTPClientFactory. This http client automatically requests, optionally renews and attaches the access tokens on each request.
28
30
2.**Manually** <Badgetext="advanced"/>: You request an access token, which you can then use to (for example) authenticate with services. You are responsible for attaching the access token to requests.
If you want to use access tokens in a different way or have more advanced needs which the automatic option doesn't cover, then you can also manually request user access tokens.
179
+
180
+
{/* prettier-ignore */}
181
+
<TabssyncKey="atm-workers">
182
+
{/* prettier-ignore */}
183
+
<TabItemlabel="V4">
171
184
172
-
publicasyncTask<IActionResult> CallApi()
185
+
You can get the current user access token manually by writing code against the `IUserTokenManager`.
The clients in the HTTP client factory have a message handler attached to them that automatically retries the request in case of a `401` response code. The request get resent with a newly requested access token. If this still results in a `401`, the response is returned to the caller.
192
192
:::
193
193
194
-
### Manual
194
+
### Manually request access tokens
195
195
196
196
If you want to use access tokens in a different way or have more advanced needs which the automatic option doesn't cover, then you can also manually request access tokens.
0 commit comments