Soenneker.Google.Ads.Client
4.0.680
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Google.Ads.Client --version 4.0.680
NuGet\Install-Package Soenneker.Google.Ads.Client -Version 4.0.680
<PackageReference Include="Soenneker.Google.Ads.Client" Version="4.0.680" />
<PackageVersion Include="Soenneker.Google.Ads.Client" Version="4.0.680" />
<PackageReference Include="Soenneker.Google.Ads.Client" />
paket add Soenneker.Google.Ads.Client --version 4.0.680
#r "nuget: Soenneker.Google.Ads.Client, 4.0.680"
#:package Soenneker.Google.Ads.Client@4.0.680
#addin nuget:?package=Soenneker.Google.Ads.Client&version=4.0.680
#tool nuget:?package=Soenneker.Google.Ads.Client&version=4.0.680
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.Gax (>= 4.0.8)
- Google.Ads.GoogleAds.Core (>= 4.0.11)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Soenneker.Extensions.Configuration (>= 4.0.895)
- Soenneker.Utils.AsyncSingleton (>= 4.0.849)
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.686 | 0 | 9/29/2026 |
| 4.0.685 | 0 | 9/28/2026 |
| 4.0.684 | 43 | 9/25/2026 |
| 4.0.683 | 43 | 9/25/2026 |
| 4.0.682 | 39 | 9/25/2026 |
| 4.0.681 | 44 | 9/24/2026 |
| 4.0.680 | 38 | 9/24/2026 |
| 4.0.679 | 60 | 9/24/2026 |
| 4.0.678 | 70 | 9/23/2026 |
| 4.0.677 | 103 | 9/16/2026 |
| 4.0.676 | 89 | 9/16/2026 |
| 4.0.675 | 95 | 9/16/2026 |
| 4.0.674 | 85 | 9/15/2026 |
| 4.0.673 | 84 | 9/15/2026 |
| 4.0.672 | 93 | 9/13/2026 |
| 4.0.671 | 89 | 9/13/2026 |
| 4.0.670 | 88 | 9/13/2026 |
| 4.0.669 | 88 | 9/13/2026 |
| 4.0.668 | 93 | 9/12/2026 |
| 4.0.667 | 93 | 9/12/2026 |
Enable Native AOT compatibility analysis