Soenneker.Google.Credentials
4.0.2626
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Google.Credentials --version 4.0.2626
NuGet\Install-Package Soenneker.Google.Credentials -Version 4.0.2626
<PackageReference Include="Soenneker.Google.Credentials" Version="4.0.2626" />
<PackageVersion Include="Soenneker.Google.Credentials" Version="4.0.2626" />
<PackageReference Include="Soenneker.Google.Credentials" />
paket add Soenneker.Google.Credentials --version 4.0.2626
#r "nuget: Soenneker.Google.Credentials, 4.0.2626"
#:package Soenneker.Google.Credentials@4.0.2626
#addin nuget:?package=Soenneker.Google.Credentials&version=4.0.2626
#tool nuget:?package=Soenneker.Google.Credentials&version=4.0.2626
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.77.0)
- Soenneker.Dictionaries.SingletonKeys (>= 4.0.166)
- Soenneker.Utils.File (>= 4.0.2292)
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 |
|---|---|---|
| 4.0.2650 | 146 | 10/15/2026 |
| 4.0.2649 | 71 | 10/14/2026 |
| 4.0.2648 | 77 | 10/14/2026 |
| 4.0.2645 | 118 | 10/14/2026 |
| 4.0.2644 | 103 | 10/14/2026 |
| 4.0.2643 | 50 | 10/14/2026 |
| 4.0.2636 | 144 | 10/13/2026 |
| 4.0.2635 | 73 | 10/13/2026 |
| 4.0.2634 | 129 | 10/12/2026 |
| 4.0.2632 | 149 | 10/12/2026 |
| 4.0.2631 | 127 | 10/12/2026 |
| 4.0.2630 | 120 | 10/12/2026 |
| 4.0.2629 | 96 | 10/12/2026 |
| 4.0.2628 | 108 | 10/12/2026 |
| 4.0.2627 | 122 | 10/11/2026 |
| 4.0.2626 | 119 | 10/11/2026 |
| 4.0.2625 | 95 | 10/11/2026 |
| 4.0.2624 | 71,702 | 9/30/2026 |
| 4.0.2623 | 155 | 9/30/2026 |
| 4.0.2622 | 4,263 | 9/29/2026 |
Update dependency Soenneker.Dictionaries.SingletonKeys to 4.0.166 (#3184)