Class GoogleAICredentials
- Namespace
- GenerativeAI
- Assembly
- GenerativeAI.dll
Represents the credentials required to authenticate with Google AI Generative APIs. This class encapsulates the API key and an optional access token necessary for making authorized API calls.
public class GoogleAICredentials : ICredentials
- Inheritance
-
GoogleAICredentials
- Implements
- Inherited Members
- Extension Methods
Constructors
GoogleAICredentials()
Represents the credentials required to authenticate with Google AI Generative APIs. Responsible for managing both the API key and optional access tokens to enable secure communication with Google's services.
public GoogleAICredentials()
GoogleAICredentials(string, AuthTokens?)
Represents the credentials required to authenticate with Google AI Generative APIs. Manages the API key and optional authentication tokens for secure API access.
public GoogleAICredentials(string apiKey, AuthTokens? authToken)
Parameters
apiKeystringauthTokenAuthTokens
GoogleAICredentials(string, string?, DateTime?)
Represents the credentials required to authenticate with Google AI Generative APIs. Manages the API Key and optional Access Token necessary for making API requests.
public GoogleAICredentials(string apiKey, string? accessToken = null, DateTime? expiry = null)
Parameters
Properties
ApiKey
Gets the API Key used to authenticate requests to Google AI Generative APIs. The API Key provides an easy way to access public resources or perform authorized operations without requiring OAuth2 tokens.
public string ApiKey { get; set; }
Property Value
AuthToken
Gets the Access Token for authenticating with Google AI APIs. This token is used for OAuth2-based authentication and is typically required when an API Key alone is insufficient for certain protected resources.
public AuthTokens? AuthToken { get; set; }
Property Value
Methods
ValidateCredentials()
Validates the API credentials for the GoogleAICredentials instance. Ensures that either an API Key or an Access Token is provided. Throws an exception if both are null or empty.
public void ValidateCredentials()
Exceptions
- Exception
Thrown when neither the API Key nor the Access Token is provided.