Documentation ¶
Overview ¶
Package gcputils provides utility functions for initializing Google API clients and services such as Google Drive and Google Slides. It simplifies the authentication process and service initialization using credentials and token caching.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCredentialCacheDir ¶
GetCredentialCacheDir returns $HOME/.credentials or an error if it does not exists
func InitDriveService ¶
InitDriveService initializes a Google Drive service using the provided context and HTTP client.
Parameters:
- ctx: The context for the service.
- client: The HTTP client for authenticating requests.
Returns:
*drive.Service: A service for interacting with Google Drive.
Errors:
- Logs a fatal error if the Drive service cannot be created.
func InitGoogleClient ¶
InitGoogleClient initializes an HTTP client for accessing Google APIs using credentials from a JSON file and a cached token file. If the token is missing or expired, the function triggers the authentication process to obtain a new token, which is then saved for future use.
Parameters:
- credentials: Path to the JSON file containing the client credentials.
- tokenCacheFile: Path to the file where the authentication token is cached.
Returns:
*http.Client: An HTTP client configured for use with Google APIs.
Errors:
- Logs a fatal error if the credentials file cannot be read or parsed.
func InitSlidesService ¶
InitSlidesService initializes a Google Slides service using the provided context and HTTP client.
Parameters:
- ctx: The context for the service.
- client: The HTTP client for authenticating requests.
Returns:
*slides.Service: A service for interacting with Google Slides.
Errors:
- Logs a fatal error if the Slides service cannot be created.
Types ¶
This section is empty.