gauth

package
v0.68.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 28 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInteractiveLoginUnavailable = errors.New("gauth: interactive Google login is unavailable in this process (go test or DATATUG_NO_BROWSER set)")
View Source
var ErrNotSignedIn = errors.New("not signed in: no stored Google refresh token")

ErrNotSignedIn is returned by TokenSource when no refresh token is stored.

Functions

func DefaultFilepath

func DefaultFilepath() (string, error)

DefaultFilepath returns a default config path for this application. On Unix-like systems: $XDG_CONFIG_HOME/firestore-viewer/service_accounts.json On macOS: ~/Library/Application Support/firestore-viewer/service_accounts.json On Windows: %AppData%/firestore-viewer/service_accounts.json

func DeleteRefreshToken

func DeleteRefreshToken() error

DeleteRefreshToken removes the stored refresh token from the keychain

func GetGCloudProjects

func GetGCloudProjects(ctx context.Context) (projects []*cloudresourcemanager.Project, err error)

func GetRefreshToken

func GetRefreshToken() (string, error)

GetRefreshToken retrieves a stored token from the keychain

func GoogleAuthCommand

func GoogleAuthCommand() *cobra.Command

func StartInteractiveLogin

func StartInteractiveLogin(ctx context.Context, scopes []string) (*oauth2.Token, error)

StartInteractiveLogin runs an interactive OAuth login with the provided scopes, stores the refresh token in keychain, and returns the acquired token.

func TokenSource added in v0.51.4

func TokenSource(ctx context.Context, scopes []string) (oauth2.TokenSource, error)

TokenSource returns a token source for the given scopes built from the refresh token stored by the Google sign-in. It returns ErrNotSignedIn when there is no stored refresh token.

Types

type FileStore

type FileStore struct {
	// Filepath is the full path to the JSON file.
	Filepath string
}

func (FileStore) Load

func (s FileStore) Load() ([]ServiceAccountDbo, error)

Load implements Store.Load.

func (FileStore) Save

func (s FileStore) Save(list []ServiceAccountDbo) error

Save implements Store.Save.

func (FileStore) Validate

func (s FileStore) Validate() error

Validate implements Validate for FileStore to comply with the project style.

type ServiceAccountDbo

type ServiceAccountDbo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

func (ServiceAccountDbo) Validate

func (sa ServiceAccountDbo) Validate() error

Validate implements the interface { Validate() error } required by the project.

type ServiceAccountsUpdatedMsg

type ServiceAccountsUpdatedMsg []ServiceAccountDbo

ServiceAccountsUpdatedMsg is emitted by fbauth UIs to notify parent models that the list of service accounts has changed. Payload is the full, current list.

type Store

type Store interface {
	// Load returns the list of service accounts and optional active index/name if needed later.
	Load() ([]ServiceAccountDbo, error)
	// Save persists the list of service accounts.
	Save([]ServiceAccountDbo) error
}

Jump to

Keyboard shortcuts

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