Table of Contents

Class GoogleServiceAccountAuthenticator

Namespace
GenerativeAI.Authenticators
Assembly
GenerativeAI.Authenticators.dll

Authenticator that uses Google Service Account credentials for authentication with Google services.

public class GoogleServiceAccountAuthenticator : BaseAuthenticator, IGoogleAuthenticator
Inheritance
GoogleServiceAccountAuthenticator
Implements
Inherited Members
Extension Methods

Constructors

GoogleServiceAccountAuthenticator(Stream)

Initializes a new instance of the GoogleServiceAccountAuthenticator class using a stream containing service account data.

public GoogleServiceAccountAuthenticator(Stream stream)

Parameters

stream Stream

Stream containing the service account JSON data.

GoogleServiceAccountAuthenticator(string?)

Authenticator class for Google services using a service account.

public GoogleServiceAccountAuthenticator(string? credentialFile)

Parameters

credentialFile string

GoogleServiceAccountAuthenticator(string, string?, string?)

Initializes a new instance of the GoogleServiceAccountAuthenticator class.

public GoogleServiceAccountAuthenticator(string serviceAccountEmail, string? certificate = null, string? passphrase = null)

Parameters

serviceAccountEmail string

The service account email address.

certificate string

Optional path to the certificate file. If null, uses default.

passphrase string

Optional passphrase for the certificate.

Methods

GetAccessTokenAsync(CancellationToken)

Retrieves an access token for the Google API.

public override Task<AuthTokens?> GetAccessTokenAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<AuthTokens>

An instance of AuthTokens representing the access token.

RefreshAccessTokenAsync(AuthTokens, CancellationToken)

Refreshes an expired access token to obtain a new one.

public override Task<AuthTokens?> RefreshAccessTokenAsync(AuthTokens token, CancellationToken cancellationToken = default)

Parameters

token AuthTokens

The expired AuthTokens instance.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<AuthTokens>

An instance of AuthTokens representing the refreshed access token.