Table of Contents

Interface IGoogleAuthenticator

Namespace
GenerativeAI.Core
Assembly
GenerativeAI.dll

Defines the contract for an authenticator to manage authentication processes for Google services.

public interface IGoogleAuthenticator
Extension Methods

Methods

GetAccessTokenAsync(CancellationToken)

Asynchronously retrieves an access token needed for authentication.

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

Parameters

cancellationToken CancellationToken

A cancellation token to cancel the operation.

Returns

Task<AuthTokens>

A task representing the asynchronous operation, containing the authentication tokens.

RefreshAccessTokenAsync(AuthTokens, CancellationToken)

Asynchronously refreshes the access token using the provided token information.

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

Parameters

token AuthTokens

The existing authentication token to be refreshed.

cancellationToken CancellationToken

A cancellation token to cancel the operation.

Returns

Task<AuthTokens>

A task representing the asynchronous operation, containing the refreshed authentication tokens.

ValidateAccessTokenAsync(string, bool, CancellationToken)

Asynchronously validates the provided access token.

Task<AuthTokens?> ValidateAccessTokenAsync(string accessToken, bool throwError = true, CancellationToken cancellationToken = default)

Parameters

accessToken string

The access token to be validated.

throwError bool

Indicates whether an error should be thrown if validation fails.

cancellationToken CancellationToken

A cancellation token to cancel the operation.

Returns

Task<AuthTokens>

A task representing the asynchronous operation. Returns the authentication tokens if the access token is valid; otherwise, null if throwError is false.