AccessTokenClient.Extensions 6.0.0-rc25

This is a prerelease version of AccessTokenClient.Extensions.
dotnet add package AccessTokenClient.Extensions --version 6.0.0-rc25
                    
NuGet\Install-Package AccessTokenClient.Extensions -Version 6.0.0-rc25
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AccessTokenClient.Extensions" Version="6.0.0-rc25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AccessTokenClient.Extensions" Version="6.0.0-rc25" />
                    
Directory.Packages.props
<PackageReference Include="AccessTokenClient.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AccessTokenClient.Extensions --version 6.0.0-rc25
                    
#r "nuget: AccessTokenClient.Extensions, 6.0.0-rc25"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AccessTokenClient.Extensions@6.0.0-rc25
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AccessTokenClient.Extensions&version=6.0.0-rc25&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AccessTokenClient.Extensions&version=6.0.0-rc25&prerelease
                    
Install as a Cake Tool

AccessTokenClient.Extensions

Service collection extension methods for registering the AccessTokenClient token client, along with a default retry policy for token requests.

Installation

dotnet add package AccessTokenClient.Extensions

Registering the Token Client

services.AddAccessTokenClient();

This registers ITokenClient, which can then be injected into controllers and services to make client credentials token requests.

Retrying Failed Token Requests

AddAccessTokenClient accepts an action that configures the IHttpClientBuilder used to register the token client. Use it to add a retry policy for requests to the token endpoint. A default policy is included:

services.AddAccessTokenClient(builder =>
{
    builder.AddPolicyHandler((provider, _) =>
    {
        var logger = provider.GetService<ILogger<ITokenClient>>();
        return AccessTokenClientPolicy.GetDefaultRetryPolicy(logger);
    });
});

The default policy retries twice, waiting one second between attempts, when a transient error (5XX or 408) or a 404 is encountered. Retries are not enabled unless a policy is added.

Caching

Access tokens are not cached by default. Use AddAccessTokenClientCache to enable caching:

services.AddMemoryCache();

services.AddAccessTokenClient().AddAccessTokenClientCache<MemoryTokenResponseCache>(options =>
{
    options.ExpirationBuffer = 5;
    options.CacheKeyPrefix   = "AccessTokenClient";
});

ExpirationBuffer is the number of minutes subtracted from the token's lifetime when it is cached, so a token is never cached longer than it is valid. A token with a lifetime that is not longer than the buffer is returned but not cached. CacheKeyPrefix is the prefix used for generated cache keys. The values shown are the defaults.

AddAccessTokenClientCache must be called after AddAccessTokenClient; an InvalidOperationException is thrown otherwise.

The type argument must implement ITokenResponseCache, so a custom cache such as a distributed cache can be used in place of MemoryTokenResponseCache.

Documentation

Full documentation is available in the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0-rc25 82 11/18/2026
6.0.0-rc24 73 11/17/2026
6.0.0-rc23 73 11/17/2026
6.0.0-rc22 71 11/17/2026
6.0.0-rc21 78 11/17/2026
6.0.0-rc20 75 11/17/2026
6.0.0-rc19 78 11/17/2026
6.0.0-rc18 77 11/17/2026
6.0.0-rc17 79 11/17/2026
5.1.0 49,908 11/19/2025
5.0.0 81,687 3/3/2025
5.0.0-rc9 219 3/1/2025
5.0.0-rc14 159 1/23/2026
5.0.0-rc13 456 11/18/2025
5.0.0-rc12 444 11/17/2025
5.0.0-rc11 280 3/3/2025
5.0.0-rc10 292 3/3/2025
3.1.0 952 2/27/2025
3.1.0-rc7 196 2/27/2025
3.1.0-rc6 210 2/27/2025
Loading failed