Documentation
¶
Overview ¶
Package auth provides authentication for Google APIs via omnitoken.
Index ¶
- func GetClient(ctx context.Context, mgr *omnitoken.TokenManager, credentialsName string) (*http.Client, error)
- func NewClient(ctx context.Context, credentialsFile string) (*http.Client, error)
- func NewClientFromCredentialsSet(ctx context.Context, credentialsFile, accountKey string) (*http.Client, error)
- func NewTokenManager(ctx context.Context, opts TokenManagerOptions) (*omnitoken.TokenManager, error)
- func Scopes() []string
- type TokenManagerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClient ¶
func GetClient(ctx context.Context, mgr *omnitoken.TokenManager, credentialsName string) (*http.Client, error)
GetClient returns an authenticated HTTP client from the TokenManager. This is a convenience function that retrieves the client for the configured credentials.
func NewClient ¶
NewClient creates an authenticated HTTP client using a Google service account credentials file. This uses the standard Google Cloud service account JSON format. Deprecated: Use NewTokenManager and TokenManager.GetClient instead.
func NewClientFromCredentialsSet ¶
func NewClientFromCredentialsSet(ctx context.Context, credentialsFile, accountKey string) (*http.Client, error)
NewClientFromCredentialsSet creates an authenticated HTTP client using a goauth CredentialsSet file. The CredentialsSet should contain a credential entry with the specified account key. The credential entry should be of type "gcpsa" with appropriate scopes configured. Deprecated: Use NewTokenManager and TokenManager.GetClient instead.
func NewTokenManager ¶
func NewTokenManager(ctx context.Context, opts TokenManagerOptions) (*omnitoken.TokenManager, error)
NewTokenManager creates an omnitoken.TokenManager configured for Google Slides access. It supports multiple credential sources:
- Google service account JSON file (serviceAccountFile)
- goauth CredentialsSet file with account key (goauthFile, goauthKey)
- Vault URI for vault-backed credentials (vaultURI, credentialsName)
Only one credential source should be provided.
Types ¶
type TokenManagerOptions ¶
type TokenManagerOptions struct {
// ServiceAccountFile is the path to a Google service account JSON file.
ServiceAccountFile string
// GoauthFile is the path to a goauth CredentialsSet JSON file.
GoauthFile string
// GoauthKey is the account key within the goauth CredentialsSet.
GoauthKey string
// VaultURI is the URI for vault-backed credentials (e.g., "op://vault", "file:///path").
VaultURI string
// CredentialsName is the name to use when storing/retrieving credentials.
// Defaults to "google-slides" if not specified.
CredentialsName string
}
TokenManagerOptions configures how to create a TokenManager.