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
streamStreamStream containing the service account JSON data.
GoogleServiceAccountAuthenticator(string?)
Authenticator class for Google services using a service account.
public GoogleServiceAccountAuthenticator(string? credentialFile)
Parameters
credentialFilestring
GoogleServiceAccountAuthenticator(string, string?, string?)
Initializes a new instance of the GoogleServiceAccountAuthenticator class.
public GoogleServiceAccountAuthenticator(string serviceAccountEmail, string? certificate = null, string? passphrase = null)
Parameters
serviceAccountEmailstringThe service account email address.
certificatestringOptional path to the certificate file. If null, uses default.
passphrasestringOptional passphrase for the certificate.
Methods
GetAccessTokenAsync(CancellationToken)
Retrieves an access token for the Google API.
public override Task<AuthTokens?> GetAccessTokenAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA 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
tokenAuthTokensThe expired AuthTokens instance.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<AuthTokens>
An instance of AuthTokens representing the refreshed access token.