AccessTokenClient.Extensions 6.0.0-rc18

This is a prerelease version of AccessTokenClient.Extensions.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AccessTokenClient.Extensions --version 6.0.0-rc18
                    
NuGet\Install-Package AccessTokenClient.Extensions -Version 6.0.0-rc18
                    
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-rc18" />
                    
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-rc18" />
                    
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-rc18
                    
#r "nuget: AccessTokenClient.Extensions, 6.0.0-rc18"
                    
#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-rc18
                    
#: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-rc18&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AccessTokenClient.Extensions&version=6.0.0-rc18&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. CacheKeyPrefix is the prefix used for generated cache keys. The values shown are the defaults.

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 91 11/18/2026
6.0.0-rc24 82 11/17/2026
6.0.0-rc23 83 11/17/2026
6.0.0-rc22 80 11/17/2026
6.0.0-rc21 86 11/17/2026
6.0.0-rc20 83 11/17/2026
6.0.0-rc19 86 11/17/2026
6.0.0-rc18 86 11/17/2026
6.0.0-rc17 88 11/17/2026
5.1.0 50,196 11/19/2025
5.0.0 81,718 3/3/2025
5.0.0-rc9 220 3/1/2025
5.0.0-rc14 160 1/23/2026
5.0.0-rc13 457 11/18/2025
5.0.0-rc12 445 11/17/2025
5.0.0-rc11 281 3/3/2025
5.0.0-rc10 293 3/3/2025
3.1.0 1,002 2/27/2025
3.1.0-rc7 197 2/27/2025
3.1.0-rc6 211 2/27/2025
Loading failed