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
- func ScopesWrite() []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.
func Scopes ¶
func Scopes() []string
Scopes returns the OAuth2 scopes required for read-only access to Google Slides, Docs, and Sheets.
func ScopesWrite ¶ added in v0.5.0
func ScopesWrite() []string
ScopesWrite returns Scopes plus drive.file, the narrowest scope that lets the server create and update files. It is requested only in write mode (--enable-write); drive.file covers just the files the app creates or opens, never the whole Drive.
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
// EnableWrite requests the extra drive.file scope for a service account
// file. Credentials from a goauth file or a vault carry their own scopes,
// which must then include drive.file.
EnableWrite bool
// 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.