Provides lazy, cached access to the generated GitHub REST API client over an authenticated shared transport.
dotnet add package Soenneker.GitHub.ClientUtil{
"GH": {
"Token": "your-github-token"
}
}using Soenneker.GitHub.ClientUtil.Registrars;
services.AddGitHubOpenApiClientUtilAsScoped();using Soenneker.GitHub.ClientUtil.Abstract;
public sealed class GitHubUserReader(IGitHubOpenApiClientUtil clients)
{
public async Task Read(CancellationToken cancellationToken)
{
var client = await clients.Get(cancellationToken);
var user = await client.User.GetAsync(
cancellationToken: cancellationToken);
}
}The HTTP provider supplies the bearer token and required GitHub headers. The generated client therefore uses anonymous Kiota authentication and does not add a duplicate Authorization value.
Use AddGitHubOpenApiClientUtilAsSingleton() when the application should share one generated client. A scoped utility borrows the singleton HTTP provider, so disposing the scope does not destroy the shared transport.