auth

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides authentication for Google APIs via omnitoken.

Index

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

func NewClient(ctx context.Context, credentialsFile string) (*http.Client, error)

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL