Soenneker.Extensions.HttpRequestDatas 11.0.173

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.HttpRequestDatas

Bearer-token parsing and unauthorized-response helpers for .NET isolated Azure Functions.

Installation

dotnet add package Soenneker.Extensions.HttpRequestDatas

Read a bearer token

using Soenneker.Extensions.HttpRequestDatas;

if (!request.TryGetBearer(out ReadOnlySpan<char> token, out string? authorizationHeader))
{
    await request.WriteUnauthorized("A bearer token is required");
    return;
}

bool valid = token.SequenceEqual(expectedToken);

TryGetBearer() reads the first nonblank Authorization header and accepts the Bearer scheme case-insensitively. Leading and trailing whitespace around the header and token are ignored. Empty tokens, tokens containing whitespace, other schemes, and headers larger than 8 KiB return false.

The returned token is a span over authorizationHeader; it does not allocate a second string. Keep the backing string in scope while using the span. If the token must survive an await or be stored, copy it first:

if (request.TryGetBearer(out ReadOnlySpan<char> token, out string? authorizationHeader))
{
    string tokenText = token.ToString();
    await ValidateToken(tokenText, cancellationToken);
}

The method extracts the credential but does not validate its signature, issuer, audience, expiry, or permissions.

Write an unauthorized result

await request.WriteUnauthorized("Invalid credentials");
return;

WriteUnauthorized() creates a 401 Unauthorized response, writes the supplied message as the body, and assigns the response to the current invocation result. A null message produces an empty body. It does not stop the function, so return immediately unless further processing is intentional.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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 Soenneker.Extensions.HttpRequestDatas:

Package Downloads
Soenneker.Entra.Middlewares.JwtAuth.Functions

Middleware for Azure Functions that validates Microsoft Entra JWTs

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.175 67 11/3/2026
11.0.174 61 11/3/2026
11.0.173 84 11/2/2026
11.0.172 112 10/27/2026
11.0.171 112 10/26/2026
11.0.170 119 10/26/2026
4.0.169 157 10/15/2026
4.0.168 95 10/14/2026
4.0.167 130 10/14/2026
4.0.166 101 10/14/2026
4.0.165 110 10/14/2026
4.0.159 112 10/13/2026
4.0.158 103 10/12/2026
4.0.156 146 10/12/2026
4.0.154 142 10/11/2026
4.0.153 109 10/11/2026
4.0.152 215 9/30/2026
4.0.151 139 9/25/2026
4.0.150 106 9/25/2026
4.0.149 101 9/24/2026
Loading failed

Updated Soenneker.Extensions.String to 11.0.807