auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides OAuth2 authentication and credential management for Google APIs.

Index

Constants

View Source
const (
	// CredentialsFile is the name of the OAuth credentials file
	// Deprecated: Use config.CredentialsFile instead
	CredentialsFile = config.CredentialsFile
	// TokenFile is the name of the OAuth token file (fallback storage)
	// Deprecated: Use config.TokenFile instead
	TokenFile = config.TokenFile
)

Re-export constants for backward compatibility

Variables

This section is empty.

Functions

func CheckScopesMigration

func CheckScopesMigration(grantedScopes []string) string

CheckScopesMigration compares the registered CLI's currently-required scopes (config.Scopes(), set by the CLI via config.Register) against the scopes a token was previously granted. It returns a non-empty, actionable message when the token is missing any now-required scope, so a CLI that has widened its scope set can prompt the user to re-authenticate. The scope set, descriptions, and product name all come from the registered identity, so the same logic serves any CLI backed by this library.

func ExchangeAuthCode

func ExchangeAuthCode(ctx context.Context, config *oauth2.Config, code string) (*oauth2.Token, error)

ExchangeAuthCode exchanges an authorization code for a token

func GetAuthURL

func GetAuthURL(config *oauth2.Config) string

GetAuthURL returns the OAuth authorization URL for the given config

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the configuration directory path, creating it if needed. Deprecated: Use config.GetConfigDir() instead

func GetCredentialsPath

func GetCredentialsPath() (string, error)

GetCredentialsPath returns the full path to credentials.json Deprecated: Use config.GetCredentialsPath() instead

func GetHTTPClient

func GetHTTPClient(ctx context.Context) (*http.Client, error)

GetHTTPClient returns an HTTP client with OAuth2 authentication. The token is read solely from the OS keyring via credstore (§1.1/§2.3 — no security/secret-tool shell-out, no token.json fallback). The active credential_ref is captured once here; refreshed tokens persist back to that exact ref via the closure passed to the token source (the sole sanctioned non-ingress keyring write). Returns an actionable error if no token exists.

func GetOAuthConfig

func GetOAuthConfig() (*oauth2.Config, error)

GetOAuthConfig loads the OAuth client config from the deployment-material OAuth client JSON referenced by config.yml's oauth_client_path (§1.2 — not a secret; lives on disk, never the keyring), with all scopes.

func GetTokenPath

func GetTokenPath() (string, error)

GetTokenPath returns the full path to token.json (fallback storage) Deprecated: Use config.GetTokenPath() instead

func ShortenPath

func ShortenPath(path string) string

ShortenPath replaces the home directory prefix with ~ for display purposes. Deprecated: Use config.ShortenPath() instead

Types

This section is empty.

Jump to

Keyboard shortcuts

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