Soenneker.Google.Ads.Client
4.0.640
Prefix Reserved
dotnet add package Soenneker.Google.Ads.Client --version 4.0.640
NuGet\Install-Package Soenneker.Google.Ads.Client -Version 4.0.640
<PackageReference Include="Soenneker.Google.Ads.Client" Version="4.0.640" />
<PackageVersion Include="Soenneker.Google.Ads.Client" Version="4.0.640" />
<PackageReference Include="Soenneker.Google.Ads.Client" />
paket add Soenneker.Google.Ads.Client --version 4.0.640
#r "nuget: Soenneker.Google.Ads.Client, 4.0.640"
#:package Soenneker.Google.Ads.Client@4.0.640
#addin nuget:?package=Soenneker.Google.Ads.Client&version=4.0.640
#tool nuget:?package=Soenneker.Google.Ads.Client&version=4.0.640
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.868)
- Soenneker.Utils.AsyncSingleton (>= 4.0.826)
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.640 | 0 | 8/30/2026 |
| 4.0.639 | 0 | 8/30/2026 |
| 4.0.638 | 0 | 8/30/2026 |
| 4.0.637 | 0 | 8/30/2026 |
| 4.0.636 | 5 | 8/30/2026 |
| 4.0.635 | 29 | 8/30/2026 |
| 4.0.634 | 38 | 8/30/2026 |
| 4.0.633 | 36 | 8/29/2026 |
| 4.0.632 | 34 | 8/29/2026 |
| 4.0.631 | 35 | 8/29/2026 |
| 4.0.630 | 40 | 8/29/2026 |
| 4.0.629 | 70 | 8/26/2026 |
| 4.0.628 | 72 | 8/26/2026 |
| 4.0.627 | 61 | 8/26/2026 |
| 4.0.626 | 71 | 8/26/2026 |
| 4.0.625 | 72 | 8/25/2026 |
| 4.0.624 | 84 | 8/22/2026 |
| 4.0.623 | 165 | 8/19/2026 |
| 4.0.622 | 83 | 8/18/2026 |
| 4.0.621 | 96 | 8/12/2026 |
Update dependency Soenneker.Extensions.Configuration to 4.0.868 (#1178)