Class AuthTokens
- Namespace
- GenerativeAI.Core
- Assembly
- GenerativeAI.dll
Represents authentication tokens used to access secure APIs or resources.
public class AuthTokens
- Inheritance
-
AuthTokens
- Inherited Members
- Extension Methods
Remarks
This class contains the necessary tokens and metadata required for authentication. It typically includes the access token, refresh token, and their expiration time. It can be used in conjunction with authenticators to manage secure access.
Constructors
AuthTokens(string, string?, DateTime?)
public AuthTokens(string accessToken, string? refreshToken = null, DateTime? expiryTime = null)
Parameters
Properties
AccessToken
Gets or sets the access token used for authenticating requests to secure APIs or resources.
public string? AccessToken { get; set; }
Property Value
Remarks
The access token is a string issued by an authentication provider, often having a limited lifetime. It is essential for granting access to protected endpoints or resources and is typically included in the authorization header of HTTP requests.
ExpiryTime
Gets or sets the expiration time of the token.
public DateTime? ExpiryTime { get; set; }
Property Value
Remarks
The ExpiryTime property indicates the exact date and time when the token becomes invalid and can no longer be used. It is important to monitor this value to refresh or renew the token before it expires, ensuring uninterrupted access to the required secure APIs or resources. Expiration time is typically provided by the authentication provider.
RefreshToken
Gets or sets the refresh token used to obtain a new access token when the current one expires.
public string? RefreshToken { get; set; }
Property Value
Remarks
The refresh token is a long-lived token issued by the authentication provider. It allows the client to request a new access token without requiring the user to re-authenticate. This property is essential for maintaining seamless access to protected resources in scenarios where the access token's lifetime is limited.
Methods
Validate()
public bool Validate()
Returns
- bool
True if the access token is valid, otherwise false.