Soenneker.Google.Ads.Client 4.0.643

Prefix Reserved
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Google.Ads.Client" Version="4.0.643" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Google.Ads.Client" Version="4.0.643" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Google.Ads.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Google.Ads.Client --version 4.0.643
                    
#r "nuget: Soenneker.Google.Ads.Client, 4.0.643"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Google.Ads.Client@4.0.643
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Google.Ads.Client&version=4.0.643
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Google.Ads.Client&version=4.0.643
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 GoogleAdsClientUtil yourself, 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Update dependency Soenneker.Extensions.Configuration to 4.0.870 (#1183)