Soenneker.Google.Credentials 4.0.2595

Prefix Reserved
dotnet add package Soenneker.Google.Credentials --version 4.0.2595
                    
NuGet\Install-Package Soenneker.Google.Credentials -Version 4.0.2595
                    
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.Credentials" Version="4.0.2595" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Google.Credentials" Version="4.0.2595" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Google.Credentials" />
                    
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.Credentials --version 4.0.2595
                    
#r "nuget: Soenneker.Google.Credentials, 4.0.2595"
                    
#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.Credentials@4.0.2595
                    
#: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.Credentials&version=4.0.2595
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Google.Credentials&version=4.0.2595
                    
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.Credentials

Loads Google service-account JSON files from an application's output directory and caches scoped credentials for reuse.

Install

dotnet add package Soenneker.Google.Credentials

Add the credential file

Keep the service-account JSON outside source control and copy it to LocalResources in the application output:

<ItemGroup>
  <Content Include="LocalResources\google-service-account.json"
           CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Get() accepts a path relative to that LocalResources directory. Absolute paths and paths that escape it are rejected.

Register

using Soenneker.Google.Credentials.Registrars;
using Microsoft.Extensions.DependencyInjection;

services.AddGoogleCredentialsUtilAsSingleton();

Singleton registration is recommended when scoped consumers should share the credential cache. Disposing a scoped consumer does not destroy this singleton. AddGoogleCredentialsUtilAsScoped() remains available when each scope deliberately needs an independent cache.

Get a scoped credential

ICredential credential = await credentials.Get(
    "google-service-account.json",
    ["https://www.googleapis.com/auth/indexing"],
    cancellationToken);

The file must contain a Google service-account credential. Application-default credentials and interactive user OAuth flows are not loaded by this package.

API at a glance

API What it does Result / important behavior
Get(fileName, scopes) Loads and scopes a credential, or returns its cached instance. Filename and ordered scope values form the cache key.
Remove(fileName, scopes) Asynchronously removes the matching cached credential. Returns whether an entry existed.
RemoveSync(fileName, scopes) Synchronously removes the matching cached credential. Useful only when asynchronous removal is not available to the caller.

Practical notes

  • Scope arrays are snapshotted when a credential is cached, so callers may safely reuse or modify their original arrays afterward.
  • Scope order is significant: the same scopes in a different order create a different cache entry.
  • Let the DI container dispose registered instances. Manually constructed instances must be disposed to release cached credentials.
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 (1)

Showing the top 1 NuGet packages that depend on Soenneker.Google.Credentials:

Package Downloads
Soenneker.Google.IndexingService

A lazy, thread-safe provider for Google Indexing API clients keyed by service-account file.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2595 0 9/9/2026
4.0.2594 39 9/9/2026
4.0.2593 40 9/9/2026
4.0.2592 51 9/8/2026
4.0.2591 85 9/8/2026
4.0.2590 100 9/7/2026
4.0.2589 102 9/7/2026
4.0.2588 98 9/7/2026
4.0.2587 104 9/7/2026
4.0.2586 138 9/5/2026
4.0.2585 87 9/5/2026
4.0.2584 115 9/5/2026
4.0.2583 109 9/4/2026
4.0.2581 113 9/4/2026
4.0.2580 107 9/4/2026
4.0.2579 111 9/4/2026
4.0.2578 112 9/4/2026
4.0.2576 134 9/4/2026
4.0.2575 99 9/4/2026
4.0.2570 180 8/30/2026
Loading failed

Update dependency Soenneker.Utils.File to 4.0.2261 (#3133)