RestSharp.Authenticators.Digest 3.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package RestSharp.Authenticators.Digest --version 3.0.0
                    
NuGet\Install-Package RestSharp.Authenticators.Digest -Version 3.0.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="RestSharp.Authenticators.Digest" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RestSharp.Authenticators.Digest" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RestSharp.Authenticators.Digest" />
                    
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 RestSharp.Authenticators.Digest --version 3.0.0
                    
#r "nuget: RestSharp.Authenticators.Digest, 3.0.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 RestSharp.Authenticators.Digest@3.0.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=RestSharp.Authenticators.Digest&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RestSharp.Authenticators.Digest&version=3.0.0
                    
Install as a Cake Tool

RestSharp.Authenticators.Digest

A lightweight and extensible Digest authentication plugin for RestSharp, implemented as an IAuthenticator.

NuGet License .NET Standard CodeQL - C#


๐Ÿ“ฆ Installation

Install via NuGet:

dotnet add package RestSharp.Authenticators.Digest

โœ… Compatibility

  • .NET Standard 2.0
  • .NET Framework 4.7.1+ (limited by RestSharp 114.0.0)
  • .NET Core 2.0+
  • .NET 5, 6, 7, 8, 9, 10+
  • Fully compatible with RestClient from RestSharp

๐Ÿš€ Quick Usage

namespace Example
{
    using RestSharp;
    using RestSharp.Authenticators.Digest;
    using System;

    public class Program
    {
        public static void Main(string[] args)
        {
            var restOptions = new RestClientOptions("https://api.myhost.com/api/v1")
            {
                Authenticator = new DigestAuthenticator(USERNAME, PASSWORD)
            };

            var client = new RestClient(restOptions);
            var request = new RestRequest("values", Method.GET);
            request.AddHeader("Content-Type", "application/json");

            var response = client.Execute(request);

            Console.WriteLine(response.StatusCode);
            Console.WriteLine(response.Content);
            Console.ReadKey(true);
        }
    }
}

โœจ Features

  • Implements HTTP Digest Authentication with support for both modern and legacy protocols:
    • RFC 2617 / RFC 7616 โ€” Full digest authentication with qop=auth, cnonce, and nonce counting
    • RFC 2069 โ€” Legacy digest authentication without qop (for older servers)
  • Automatic protocol detection โ€” the library reads the server's WWW-Authenticate challenge and selects the correct hash format
  • Nonce, realm, opaque, and qop support
  • Compatible with servers that require WWW-Authenticate: Digest
  • Stateless and thread-safe
  • Works with RestClient and IRestRequest out of the box

๐Ÿ” Protocol Support

The library automatically detects which protocol the server uses based on the WWW-Authenticate response header. No configuration is needed โ€” the same code works for both protocols.

RFC 2617 / RFC 7616 (modern servers)

When the server includes qop in its challenge (e.g., qop="auth" or qop="auth,auth-int"), the library uses the full digest scheme:

response = MD5(MD5(username:realm:password):nonce:nc:cnonce:qop:MD5(method:uri))

The generated Authorization header includes qop, nc, and cnonce fields.

RFC 2069 (legacy servers)

When the server does not include qop in its challenge, the library falls back to the simplified RFC 2069 scheme:

response = MD5(MD5(username:realm:password):nonce:MD5(method:uri))

The generated Authorization header omits qop, nc, and cnonce fields, as required by the legacy protocol.

Usage

The usage is identical for both protocols โ€” just create the authenticator and let the library handle the rest:

var restOptions = new RestClientOptions("https://api.myhost.com/api/v1")
{
    Authenticator = new DigestAuthenticator("username", "password")
};

var client = new RestClient(restOptions);
var request = new RestRequest("resource");
var response = await client.ExecuteAsync(request);

This works transparently whether the server uses RFC 2069 or RFC 2617/7616.


๐Ÿงช Testing

The project includes comprehensive unit and integration tests covering both RFC 2069 and RFC 2617/7616 protocols.

Integration tests use embedded HTTP listeners that simulate digest servers for both protocols.

Tests target multiple frameworks (net8.0, net10.0).


๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿค Contributing

Contributions are welcome!

If you find a bug or have an idea for improvement:

Please follow the contribution guidelines if available.


๐Ÿ“ฌ Contact

Maintained by @thenoobsbr NuGet Package: RestSharp.Authenticators.Digest

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 was computed.  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 was computed.  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 was computed.  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 was computed. 
.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 (1)

Showing the top 1 NuGet packages that depend on RestSharp.Authenticators.Digest:

Package Downloads
SmartHomeClassLib

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1-rc.6 29 4/7/2026
3.0.1-rc.5 30 4/7/2026
3.0.0 94 4/7/2026
3.0.0-rc.3 36 4/7/2026
2.1.0 12,223 6/19/2025
2.0.0 30,852 6/17/2024
1.6.0 66,241 8/4/2023
1.5.0 1,889 7/10/2023
1.4.0 1,268 7/10/2023
1.3.1 18,791 4/13/2022
1.3.0 5,829 2/2/2022
1.2.0 139,551 12/21/2021
1.1.0 5,291 11/29/2021
1.0.2 72,244 2/26/2020
1.0.1 2,548 9/17/2019
1.0.0 1,546 8/23/2019

# Release notes

## v3.0.0

- Updates RestSharp dependency to version 114.0.0;
- Adds CancellationToken support to the Authenticate method (IAuthenticator breaking change in RestSharp 114);
- Threads CancellationToken through the digest handshake pipeline;
- Adds backward compatibility layer (DigestAuthenticatorLegacy) for consumers upgrading from v2.x;
- Drops net6.0 test target (EOL);
- Adds comprehensive unit tests for DigestAuthenticator, DigestHeader, DigestAuthenticatorManager, and
 DigestAuthenticatorLegacy;
- Adds integration tests for error scenarios, wrong credentials, multiple HTTP methods, and concurrent requests;

## v1.4.0

- Fixies the authentication when the qop value comes without `"`;
- Updates packages;
- Adds a real integration tests;

## v1.5.0

- Adjusts the nuget package;
- Adds optional ILogger to the DigestAuthenticator constructor;
- Adds optional request timeout to the DigestAuthenticator constructor;

## v1.6.0

- GetDigestAuthHeader should inherit proxy;

## v2.0.0

- Changes the compatibility to the RestSharp version `111.2.0` or greater.

## v2.1.0

- Add ability to change client options from digest RestClient object