Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

GoogleServiceAccountCredentialSource

OfficeIMO.GoogleWorkspace

Namespace
OfficeIMO.GoogleWorkspace
Assembly
OfficeIMO.GoogleWorkspace
Source revision
be6c300e4ab1 with working tree changes
Implements
IGoogleWorkspaceCredentialSource IDisposable
Modifiers
sealed

Credential source that acquires Google access tokens by exchanging a signed service-account JWT assertion.

Inheritance

  • object
  • GoogleServiceAccountCredentialSource

Usage

Explore 2 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Constructors

public GoogleServiceAccountCredentialSource(string clientEmail, string privateKeyPem, string? tokenEndpoint = null, GoogleWorkspaceSessionOptions? sessionOptions = null) #

Creates a service-account credential source from an email identity and PKCS#8 PEM private key.

Parameters

clientEmail string required
Service-account email used as the JWT issuer.
privateKeyPem string required
RSA private key in PEM form used to sign JWT assertions.
tokenEndpoint string? = null optional
OAuth token endpoint, or null for Google's default endpoint.
sessionOptions OfficeIMO.GoogleWorkspace.GoogleWorkspaceSessionOptions? = null optional
Optional delegation, HTTP-client, and timeout settings.

Methods

public async Task<GoogleWorkspaceAccessToken> AcquireAccessTokenAsync(IEnumerable<string> scopes, CancellationToken cancellationToken = default) #

Acquires an access token and its available scope evidence for the requested operation.

Parameters

scopes System.Collections.Generic.IEnumerable<string> required
OAuth scopes required by the pending operation.
cancellationToken System.Threading.CancellationToken = default optional
Token used to cancel acquisition.

Returns

Task<GoogleWorkspaceAccessToken> A task that produces the acquired token and its scope and identity evidence. Callers must verify that the evidence covers their required scopes.
public void Dispose() #

Releases the token-cache lock and the internally created HTTP client, if any.

public static GoogleServiceAccountCredentialSource FromFile(string serviceAccountJsonPath, GoogleWorkspaceSessionOptions? sessionOptions = null) #

Creates a credential source from a Google service-account JSON file.

Parameters

serviceAccountJsonPath string required
Path to the service-account JSON file.
sessionOptions OfficeIMO.GoogleWorkspace.GoogleWorkspaceSessionOptions? = null optional
Optional delegation, HTTP-client, and timeout settings.

Returns

GoogleServiceAccountCredentialSource A configured credential source.
public static GoogleServiceAccountCredentialSource FromJson(string serviceAccountJson, GoogleWorkspaceSessionOptions? sessionOptions = null) #

Creates a credential source from a Google service-account JSON document.

Parameters

serviceAccountJson string required
JSON containing client_email, private_key, and optionally token_uri.
sessionOptions OfficeIMO.GoogleWorkspace.GoogleWorkspaceSessionOptions? = null optional
Optional delegation, HTTP-client, and timeout settings.

Returns

GoogleServiceAccountCredentialSource A configured credential source.

Properties

public string ClientEmail { get; } #

Gets the service-account email used as the JWT issuer.

public string TokenEndpoint { get; } #

Gets the OAuth endpoint used to exchange signed JWT assertions.

public string? SubjectUser { get; } #

Gets the Workspace user to impersonate when domain-wide delegation is enabled.

public bool UseDomainWideDelegation { get; } #

Gets whether domain-wide delegation was requested for generated JWT assertions.

public TimeSpan TokenLifetime { get; } #

Gets the requested lifetime of signed JWT assertions and fallback access-token lifetime.

public TimeSpan RefreshSkew { get; } #

Gets how early a cached token is refreshed before its expiry.