Soenneker.Google.Credentials
4.0.2579
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Google.Credentials --version 4.0.2579
NuGet\Install-Package Soenneker.Google.Credentials -Version 4.0.2579
<PackageReference Include="Soenneker.Google.Credentials" Version="4.0.2579" />
<PackageVersion Include="Soenneker.Google.Credentials" Version="4.0.2579" />
<PackageReference Include="Soenneker.Google.Credentials" />
paket add Soenneker.Google.Credentials --version 4.0.2579
#r "nuget: Soenneker.Google.Credentials, 4.0.2579"
#:package Soenneker.Google.Credentials@4.0.2579
#addin nuget:?package=Soenneker.Google.Credentials&version=4.0.2579
#tool nuget:?package=Soenneker.Google.Credentials&version=4.0.2579
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 | 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.Apis.Auth (>= 1.76.0)
- Soenneker.Dictionaries.SingletonKeys (>= 4.0.139)
- Soenneker.Utils.File (>= 4.0.2247)
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.2583 | 0 | 9/4/2026 |
| 4.0.2581 | 0 | 9/4/2026 |
| 4.0.2580 | 0 | 9/4/2026 |
| 4.0.2579 | 34 | 9/4/2026 |
| 4.0.2578 | 44 | 9/4/2026 |
| 4.0.2576 | 48 | 9/4/2026 |
| 4.0.2575 | 42 | 9/4/2026 |
| 4.0.2570 | 169 | 8/30/2026 |
| 4.0.2569 | 143 | 8/30/2026 |
| 4.0.2568 | 104 | 8/30/2026 |
| 4.0.2567 | 115 | 8/29/2026 |
| 4.0.2565 | 95 | 8/29/2026 |
| 4.0.2564 | 81 | 8/29/2026 |
| 4.0.2563 | 87 | 8/29/2026 |
| 4.0.2562 | 209 | 8/26/2026 |
| 4.0.2561 | 109 | 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 | 123 | 8/21/2026 |
Updated Soenneker.Dictionaries.SingletonKeys to 4.0.139