TypedRest.OAuth 1.7.0

dotnet add package TypedRest.OAuth --version 1.7.0
                    
NuGet\Install-Package TypedRest.OAuth -Version 1.7.0
                    
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="TypedRest.OAuth" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TypedRest.OAuth" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="TypedRest.OAuth" />
                    
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 TypedRest.OAuth --version 1.7.0
                    
#r "nuget: TypedRest.OAuth, 1.7.0"
                    
#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 TypedRest.OAuth@1.7.0
                    
#: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=TypedRest.OAuth&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=TypedRest.OAuth&version=1.7.0
                    
Install as a Cake Tool

TypedRest OAuth

Adds support for OAuth 2.0 / OpenID Connect authentication to HttpClient.

dotnet add package TypedRest.OAuth

This provides an HttpClient DelegatingHandler that transparently requests access tokens with a client secret and caches them until they expire. It can be used independently of the other TypedRest packages.

Call .AddOAuthHandler() after .AddTypedRest():

services.AddTypedRest<MyClient>(new Uri("https://example.com/api/"))
        .AddOAuthHandler(new Uri("https://identity.example.com/"), clientId: "my-client", clientSecret: "…");

or after .AddHttpClient() when you are not using the main TypedRest package:

services.AddHttpClient<MyService>()
        .AddOAuthHandler(options =>
        {
            options.Uri = new Uri("https://identity.example.com/");
            options.ClientId = "my-client";
            options.ClientSecret = "…";
        });

OAuthOptions carries the settings for that flow. The Action<OAuthOptions> overload registers them as named options under the HTTP client's name, so different clients in the same application can authenticate against different identity servers and the settings can also come from configuration. To keep the client secret out of your code, build the options from configuration instead:

services.AddTypedRest<MyClient>(new Uri("https://example.com/api/"))
        .AddOAuthHandler(_ => configuration.GetSection("OAuth").Get<OAuthOptions>()!);

OAuthHandler sits in the HttpClient pipeline and keeps authentication out of your calling code entirely. On the first request it looks up the token endpoint via OpenID Connect discovery, performs a client credentials flow and attaches the resulting token as a Bearer header. The token is then reused for subsequent requests until shortly before it expires, so the identity server is contacted only occasionally rather than per request. If a server rejects a token as invalid anyway, the request is retried once with a freshly requested one.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
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
1.7.0 88 8/2/2026
1.6.6 87 8/1/2026
1.6.5 133 5/17/2026
1.6.4 114 5/2/2026
1.6.3 171 2/15/2026
1.6.2 195 12/20/2025
1.6.1 298 9/8/2025
1.6.0 309 12/15/2024
1.5.4 448 9/8/2024
1.5.3 277 7/7/2024
1.5.2 281 12/27/2023
1.5.1 254 10/4/2023
1.5.0 235 10/3/2023
1.4.1 240 10/1/2023
1.4.0 240 9/30/2023
1.3.8 435 3/12/2023
1.3.7 478 11/28/2022
1.3.6 2,410 11/29/2021
1.3.5 1,487 9/5/2021
1.3.4 1,871 1/29/2021
Loading failed