Table of Contents

HttpAuthenticationSchemes Class

Definition

Namespace
Cuemon.Net.Http
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Net/Http/HttpAuthenticationSchemes.cs

Defines constants for well-known HTTP authentication schemes.

public static class HttpAuthenticationSchemes
Inheritance
HttpAuthenticationSchemes

Examples

The following example shows how to use the HttpAuthenticationSchemes constants to construct HTTP Authorization headers. It prints each scheme name and creates a Basic authentication header value.

using System;
using System.Net.Http.Headers;
using System.Text;
using Cuemon.Net.Http;

namespace MyApp.Examples;

public static class HttpAuthenticationSchemesExample
{
    public static void Demonstrate()
    {
        // Use scheme constants to construct Authorization headers
        string basic = HttpAuthenticationSchemes.Basic;
        string bearer = HttpAuthenticationSchemes.Bearer;
        string digest = HttpAuthenticationSchemes.Digest;

        Console.WriteLine($"Basic: {basic}");
        Console.WriteLine($"Bearer: {bearer}");
        Console.WriteLine($"Digest: {digest}");

        // Example: create a Basic authentication header value
        string credentials = Convert.ToBase64String(
            Encoding.UTF8.GetBytes("user:password"));
        string authHeader = $"{basic} {credentials}";
        Console.WriteLine($"Authorization: {authHeader}");
    }
}

Fields

Name Description
Basic

The Basic HTTP Authentication Scheme.

Bearer

The Bearer HTTP Authentication Scheme.

Digest

The Digest HTTP Authentication Scheme.

Hoba

The HOBA HTTP Authentication Scheme.

Mutual

The Mutual HTTP Authentication Scheme.

Negotiate

The Negotiate HTTP Authentication Scheme.

ScramSha1

The SCRAM-SHA-1 HTTP Authentication Scheme.

ScramSha256

The SCRAM-SHA-256 HTTP Authentication Scheme.

Vapid

The vapid HTTP Authentication Scheme.