Soenneker.Google.Credentials 4.0.2575

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Google.Credentials --version 4.0.2575
                    
NuGet\Install-Package Soenneker.Google.Credentials -Version 4.0.2575
                    
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.2575" />
                    
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.2575" />
                    
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.2575
                    
#r "nuget: Soenneker.Google.Credentials, 4.0.2575"
                    
#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.2575
                    
#: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.2575
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Google.Credentials&version=4.0.2575
                    
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.2579 0 9/4/2026
4.0.2578 0 9/4/2026
4.0.2576 0 9/4/2026
4.0.2575 0 9/4/2026
4.0.2570 153 8/30/2026
4.0.2569 134 8/30/2026
4.0.2568 99 8/30/2026
4.0.2567 111 8/29/2026
4.0.2565 94 8/29/2026
4.0.2564 81 8/29/2026
4.0.2563 85 8/29/2026
4.0.2562 193 8/26/2026
4.0.2561 108 8/26/2026
4.0.2560 113 8/26/2026
4.0.2559 143 8/22/2026
4.0.2558 119 8/21/2026
4.0.2557 122 8/21/2026
4.0.2556 135 8/20/2026
4.0.2555 143 8/19/2026
4.0.2554 122 8/18/2026
Loading failed

Updated Multiple NuGet packages