Soenneker.X.ClientUtil
11.0.535
Prefix Reserved
dotnet add package Soenneker.X.ClientUtil --version 11.0.535
NuGet\Install-Package Soenneker.X.ClientUtil -Version 11.0.535
<PackageReference Include="Soenneker.X.ClientUtil" Version="11.0.535" />
<PackageVersion Include="Soenneker.X.ClientUtil" Version="11.0.535" />
<PackageReference Include="Soenneker.X.ClientUtil" />
paket add Soenneker.X.ClientUtil --version 11.0.535
#r "nuget: Soenneker.X.ClientUtil, 11.0.535"
#:package Soenneker.X.ClientUtil@11.0.535
#addin nuget:?package=Soenneker.X.ClientUtil&version=11.0.535
#tool nuget:?package=Soenneker.X.ClientUtil&version=11.0.535
Soenneker.X.ClientUtil
Provides a lazily created, cached XOpenApiClient that authenticates every request with one configured bearer token.
Installation
dotnet add package Soenneker.X.ClientUtil
Configuration
{
"X": {
"BearerToken": "your-app-bearer-token"
}
}
X:ApiKey remains supported as a legacy configuration key.
Registration
Register one client for the application:
services.AddXClientUtilAsSingleton();
Or register the OpenAPI client provider per scope while retaining the singleton HTTP transport:
services.AddXClientUtilAsScoped();
Usage
public sealed class XSearchService
{
private readonly IXClientUtil _xClientUtil;
public XSearchService(IXClientUtil xClientUtil)
{
_xClientUtil = xClientUtil;
}
public async Task SearchUsers(CancellationToken cancellationToken)
{
XOpenApiClient client = await _xClientUtil.Get(cancellationToken);
var response = await client.Two.Users.Search.GetAsync(request =>
{
request.QueryParameters.Query = "dotnet";
}, cancellationToken);
foreach (var user in response?.Data ?? [])
Console.WriteLine($"{user.Name} (@{user.Username})");
}
}
This package captures one bearer token when the provider is created, so it fits app-only access and other endpoints that accept that token. For requests made on behalf of different users, use Soenneker.X.Client and attach the appropriate OAuth token to each request instead of sharing it through this client.
Disposing a scoped IXClientUtil releases its generated client; it does not remove the singleton HTTP transport.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Kiota.BearerAuthenticationProvider (>= 11.0.64)
- Soenneker.X.Client (>= 11.0.338)
- Soenneker.X.OpenApiClient (>= 11.0.285)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.X.ClientUtil:
| Package | Downloads |
|---|---|
|
Soenneker.X.Users
Utilities for X users and creating posts. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.535 | 0 | 10/27/2026 |
| 11.0.534 | 0 | 10/27/2026 |
| 11.0.533 | 0 | 10/27/2026 |
| 11.0.532 | 0 | 10/27/2026 |
| 11.0.531 | 6 | 10/26/2026 |
| 11.0.530 | 38 | 10/26/2026 |
| 11.0.529 | 42 | 10/26/2026 |
| 4.0.528 | 51 | 10/26/2026 |
| 4.0.527 | 54 | 10/25/2026 |
| 4.0.526 | 70 | 10/24/2026 |
| 4.0.525 | 67 | 10/23/2026 |
| 4.0.524 | 61 | 10/22/2026 |
| 4.0.523 | 77 | 10/21/2026 |
| 4.0.522 | 114 | 10/19/2026 |
| 4.0.521 | 108 | 10/18/2026 |
| 4.0.520 | 103 | 10/17/2026 |
| 4.0.519 | 105 | 10/15/2026 |
| 4.0.518 | 109 | 10/15/2026 |
| 4.0.517 | 103 | 10/15/2026 |
| 4.0.516 | 102 | 10/15/2026 |
Remove redundant framework conditions