Soenneker.Google.Ads.Client
4.0.643
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Google.Ads.Client --version 4.0.643
NuGet\Install-Package Soenneker.Google.Ads.Client -Version 4.0.643
<PackageReference Include="Soenneker.Google.Ads.Client" Version="4.0.643" />
<PackageVersion Include="Soenneker.Google.Ads.Client" Version="4.0.643" />
<PackageReference Include="Soenneker.Google.Ads.Client" />
paket add Soenneker.Google.Ads.Client --version 4.0.643
#r "nuget: Soenneker.Google.Ads.Client, 4.0.643"
#:package Soenneker.Google.Ads.Client@4.0.643
#addin nuget:?package=Soenneker.Google.Ads.Client&version=4.0.643
#tool nuget:?package=Soenneker.Google.Ads.Client&version=4.0.643
Soenneker.Google.Ads.Client
A lazy, thread-safe GoogleAdsClient provider with dependency-injection registration and deterministic disposal.
Install
dotnet add package Soenneker.Google.Ads.Client
Configuration
{
"Google": {
"Ads": {
"DeveloperToken": "<developer token>",
"ClientId": "<OAuth client ID>",
"ClientSecret": "<OAuth client secret>"
}
}
}
The values are read when Get() first creates the client, not during service registration.
Registration
using Soenneker.Google.Ads.Client.Registrars;
using Microsoft.Extensions.DependencyInjection;
services.AddGoogleAdsClientUtilAsSingleton();
Singleton registration is the normal choice for this package: callers and scoped utilities can share the long-lived Google Ads client while their own scopes are disposed independently.
AddGoogleAdsClientUtilAsScoped() is available when a separate client really is required per scope; disposing the scope then disposes that scope's provider and client.
Usage
public sealed class CampaignReader
{
private readonly IGoogleAdsClientUtil _clientUtil;
public CampaignReader(IGoogleAdsClientUtil clientUtil)
{
_clientUtil = clientUtil;
}
public async ValueTask<GoogleAdsClient> GetClient(CancellationToken cancellationToken)
{
return await _clientUtil.Get(cancellationToken);
}
}
Every Get() call on the same provider returns the same lazily created GoogleAdsClient. Concurrent first calls share one initialization.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
Get(cancellationToken) |
Gets or creates the configured client. | Reuses one client for the lifetime of the provider. |
AddGoogleAdsClientUtilAsSingleton() |
Registers one provider for the application. | Recommended for sharing the client across scoped consumers. |
AddGoogleAdsClientUtilAsScoped() |
Registers one provider per DI scope. | Each scope creates and owns a separate client. |
Practical notes
- Let the DI container dispose registered instances. If you construct
GoogleAdsClientUtilyourself, dispose it asynchronously or synchronously when finished. - Cancellation affects pending lazy initialization. It does not cancel operations performed later through the returned Google Ads client.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Google.Ads.GoogleAds (>= 27.2.0)
- Soenneker.Extensions.Configuration (>= 4.0.870)
- Soenneker.Utils.AsyncSingleton (>= 4.0.829)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.646 | 0 | 8/31/2026 |
| 4.0.645 | 0 | 8/31/2026 |
| 4.0.644 | 0 | 8/31/2026 |
| 4.0.643 | 0 | 8/31/2026 |
| 4.0.642 | 31 | 8/31/2026 |
| 4.0.641 | 28 | 8/31/2026 |
| 4.0.640 | 34 | 8/30/2026 |
| 4.0.639 | 37 | 8/30/2026 |
| 4.0.638 | 40 | 8/30/2026 |
| 4.0.637 | 41 | 8/30/2026 |
| 4.0.636 | 39 | 8/30/2026 |
| 4.0.635 | 37 | 8/30/2026 |
| 4.0.634 | 41 | 8/30/2026 |
| 4.0.633 | 39 | 8/29/2026 |
| 4.0.632 | 36 | 8/29/2026 |
| 4.0.631 | 37 | 8/29/2026 |
| 4.0.630 | 41 | 8/29/2026 |
| 4.0.629 | 70 | 8/26/2026 |
| 4.0.628 | 72 | 8/26/2026 |
| 4.0.627 | 65 | 8/26/2026 |
Update dependency Soenneker.Extensions.Configuration to 4.0.870 (#1183)