![]() |
VOOZH | about |
dotnet add package Tingle.Extensions.Http.Authentication --version 5.3.0
NuGet\Install-Package Tingle.Extensions.Http.Authentication -Version 5.3.0
<PackageReference Include="Tingle.Extensions.Http.Authentication" Version="5.3.0" />
<PackageVersion Include="Tingle.Extensions.Http.Authentication" Version="5.3.0" />Directory.Packages.props
<PackageReference Include="Tingle.Extensions.Http.Authentication" />Project file
paket add Tingle.Extensions.Http.Authentication --version 5.3.0
#r "nuget: Tingle.Extensions.Http.Authentication, 5.3.0"
#:package Tingle.Extensions.Http.Authentication@5.3.0
#addin nuget:?package=Tingle.Extensions.Http.Authentication&version=5.3.0Install as a Cake Addin
#tool nuget:?package=Tingle.Extensions.Http.Authentication&version=5.3.0Install as a Cake Tool
This library adds support for custom authentication via the Authorization header when using HttpClient. In some cases, setting the header once is not sufficient. Instead you may want to refresh the token only after it expires.
This functionality builds upon the DelegatingHandler and hence can be used via DI using IHttpClientBuilder or without by wrapping inner handlers.
Also see .
The supported authentication patterns:
Authorization headerExample:
builder.Services.AddHttpClient<MyCustomClient>()
.AddApiKeyHeaderAuthenticationHandler("my-api-key-here", scheme: "Bearer");
This will add an Authorization header → Authorization: Bearer my-api-key-here
Example:
builder.Services.AddHttpClient<MyCustomClient>()
.AddApiKeyQueryAuthenticationHandler("my-api-key-here", queryParameterName: "key");
This will append to the query string of the request before the request is sent out. E.g. https://contoso.com/?key=my-api-key-here
Authorization headerThis behaves similar to Microsoft's shared key authentication which you can also use in your own projects. Every request ends up with a different authorization value and can be safer in some situations compared to using OAuth.
builder.Services.AddHttpClient($"{nameof(Worker)}4")
.AddSharedKeyAuthenticationHandler("my-base-64-encoded-key", scheme: "Bearer");
This will add an Authorization here → Authorization: Bearer {base64-request-hash-will-be-set-here}
This follows the OAuth 2.0 client_credentials flow and optionally caches access tokens using IMemoryCache or IDistributedCache for the duration it is valid.
Example:
builder.Services.AddMemoryCache();
builder.Services.AddDistributedMemoryCache();
builder.Services.AddHttpClient<MyCustomClient>()
.AddAuthenticationHandler(provider => new OAuthClientCredentialHandler()
{
Scheme = "Bearer",
// set OAuth values to match your scenario
AuthenticationEndpoint = "https://oauth-1.contoso.com",
Resource = "https://api.contoso.com",
ClientId = "awesome-app-id",
ClientSecret = "super-secret",
Logger = provider.GetRequiredService<ILogger<Program>>(), // optional, useful for debugging
// caching can be disabled by setting either CacheKey or Cache to null
CacheKey = $"{nameof(MyCustomClient)}:auth-token",
// either IMemoryCache or IDistributedCache
Cache = new(provider.GetRequiredService<Microsoft.Extensions.Caching.Memory.IMemoryCache>()),
//Cache = new(provider.GetRequiredService<Microsoft.Extensions.Caching.Distributed.IDistributedCache>()),
});
Works like OAuth Client Credentials with a slight customization for Azure AD by setting the AuthorizationEndpoint based on the value supplied for TenantId.
Example:
builder.Services.AddMemoryCache();
builder.Services.AddDistributedMemoryCache();
builder.Services.AddHttpClient<MyCustomClient>()
.AddAuthenticationHandler(provider => new AzureAdB2BHandler
{
Scheme = "Bearer",
// set OAuth values to match your scenario
TenantId = "00000000-0000-1111-0001-000000000000",
Resource = "https://api.contoso.com",
ClientId = "awesome-app-id",
ClientSecret = "super-secret",
Logger = provider.GetRequiredService<ILogger<Program>>(), // optional, useful for debugging
// caching can be disabled by setting either CacheKey or Cache to null
CacheKey = $"{nameof(MyCustomClient)}:auth-token",
// either IMemoryCache or IDistributedCache
Cache = new(provider.GetRequiredService<Microsoft.Extensions.Caching.Memory.IMemoryCache>()),
//Cache = new(provider.GetRequiredService<Microsoft.Extensions.Caching.Distributed.IDistributedCache>()),
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on Tingle.Extensions.Http.Authentication:
| Package | Downloads |
|---|---|
|
Tingle.Extensions.PushNotifications
Clients for sending push notifications via FCM, APNS etc |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.3.0 | 541 | 8/26/2025 |
| 5.2.0 | 1,148 | 4/21/2025 |
| 5.1.1 | 370 | 4/20/2025 |
| 5.1.0 | 315 | 4/20/2025 |
| 5.0.1 | 618 | 2/21/2025 |
| 5.0.0 | 541 | 11/19/2024 |
| 4.14.1 | 710 | 10/14/2024 |
| 4.14.0 | 601 | 9/16/2024 |
| 4.13.0 | 854 | 8/13/2024 |
| 4.12.0 | 381 | 8/7/2024 |
| 4.11.2 | 566 | 7/15/2024 |
| 4.11.1 | 597 | 6/26/2024 |
| 4.11.0 | 489 | 6/6/2024 |
| 4.10.1 | 305 | 6/5/2024 |
| 4.10.0 | 396 | 5/27/2024 |
| 4.9.0 | 523 | 5/16/2024 |
| 4.8.0 | 569 | 5/5/2024 |
| 4.7.0 | 765 | 3/25/2024 |
| 4.6.0 | 616 | 3/8/2024 |
| 4.5.0 | 2,258 | 11/22/2023 |