Table of Contents

BasicAuthorizationHeader Class

Definition

Provides a representation of a HTTP Basic Authentication header. Implements the AuthorizationHeader

public class BasicAuthorizationHeader : AuthorizationHeader
Inheritance
BasicAuthorizationHeader
Inherited Members

Examples

The following example demonstrates how to serialize and parse a Basic authorization header.

using System;
using Cuemon.AspNetCore.Authentication.Basic;

namespace MyApp.Examples;

public static class BasicAuthorizationHeaderExample
{
    public static void Demonstrate()
    {
        var header = new BasicAuthorizationHeader("Agent", "Test");
        var parsed = BasicAuthorizationHeader.Create(header.ToString());

        Console.WriteLine(parsed.UserName);
        Console.WriteLine(parsed.Password);
    }
}

Constructors

Name Description
BasicAuthorizationHeader(string, string)

Initializes a new instance of the BasicAuthorizationHeader class.

Fields

Name Description
Scheme

The default authentication scheme of the BasicAuthorizationHeader.

Properties

Name Description
Password

Gets the password of the credentials.

UserName

Gets the username of the credentials.

Methods

Name Description
Create(string)

Creates an instance of BasicAuthorizationHeader from the specified parameters.

Parse(string, Action<AuthorizationHeaderOptions>)

Parses the specified authorizationHeader.

ParseCore(IReadOnlyDictionary<string, string>)

The core parser that resolves an AuthorizationHeader from a set of credentials.

ToString()

Returns a string that represents this instance.

See Also