Soenneker.Google.Credentials
11.0.2685
Prefix Reserved
dotnet add package Soenneker.Google.Credentials --version 11.0.2685
NuGet\Install-Package Soenneker.Google.Credentials -Version 11.0.2685
<PackageReference Include="Soenneker.Google.Credentials" Version="11.0.2685" />
<PackageVersion Include="Soenneker.Google.Credentials" Version="11.0.2685" />
<PackageReference Include="Soenneker.Google.Credentials" />
paket add Soenneker.Google.Credentials --version 11.0.2685
#r "nuget: Soenneker.Google.Credentials, 11.0.2685"
#:package Soenneker.Google.Credentials@11.0.2685
#addin nuget:?package=Soenneker.Google.Credentials&version=11.0.2685
#tool nuget:?package=Soenneker.Google.Credentials&version=11.0.2685
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Google.Apis.Auth (>= 1.78.0)
- Soenneker.Dictionaries.SingletonKeys (>= 11.0.206)
- Soenneker.Utils.File (>= 11.0.2348)
NuGet packages (3)
Showing the top 3 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. |
|
|
Soenneker.Google.DataManager.Client
Provides a shared authenticated Google Data Manager API client. |
|
|
Soenneker.Google.SearchConsole
A utility library for Google Search Console. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.2685 | 0 | 11/19/2026 |
| 11.0.2684 | 0 | 11/19/2026 |
| 11.0.2683 | 10 | 11/18/2026 |
| 11.0.2682 | 10 | 11/18/2026 |
| 11.0.2681 | 13 | 11/18/2026 |
| 11.0.2678 | 308 | 11/15/2026 |
| 11.0.2677 | 167 | 11/15/2026 |
| 11.0.2676 | 870 | 11/11/2026 |
| 11.0.2675 | 125 | 11/11/2026 |
| 11.0.2674 | 147 | 11/11/2026 |
| 11.0.2673 | 151 | 11/11/2026 |
| 11.0.2672 | 131 | 11/11/2026 |
| 11.0.2671 | 227 | 11/11/2026 |
| 11.0.2670 | 114 | 11/11/2026 |
| 11.0.2669 | 91 | 11/11/2026 |
| 11.0.2668 | 125 | 11/11/2026 |
| 11.0.2667 | 17,856 | 11/3/2026 |
| 11.0.2666 | 162 | 11/3/2026 |
| 11.0.2665 | 131 | 11/3/2026 |
| 11.0.2664 | 144 | 11/3/2026 |
Updated Soenneker.Utils.File to 11.0.2348