auth

package
v0.0.0-...-cfb22d8 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteToken

func DeleteToken() error

DeleteToken removes the OAuth token from the keychain

func GetToken

func GetToken() (*oauth2.Token, error)

GetToken retrieves the OAuth token from the OS keychain

func GetValidToken

func GetValidToken(clientSecretPath string) (*oauth2.Token, error)

GetValidToken returns a valid token, refreshing if necessary

func HasToken

func HasToken() bool

HasToken checks if a token exists in the keychain

func LoadClientConfig

func LoadClientConfig(clientSecretPath string) (*oauth2.Config, error)

LoadClientConfig loads OAuth2 config from client_secret.json

func LoginFlow

func LoginFlow(clientSecretPath string) (*oauth2.Token, error)

LoginFlow performs the OAuth2 login flow with browser-based consent

func RefreshToken

func RefreshToken(clientSecretPath string, token *oauth2.Token) (*oauth2.Token, error)

RefreshToken refreshes an expired token

func SetToken

func SetToken(token *oauth2.Token) error

SetToken stores the OAuth token in the OS keychain

Types

type Identity

type Identity struct {
	Email            string
	Scopes           []string
	Audience         string
	HasSearchConsole bool
	HasEmail         bool
}

Identity describes who a stored token belongs to and what it is allowed to do. Email is empty unless the token was granted an identity scope, so an older token reports its scopes but not its account - that gap is itself the answer when 'sites' comes back empty.

func FetchIdentity

func FetchIdentity(ctx context.Context, token *oauth2.Token) (*Identity, error)

FetchIdentity asks Google who this access token belongs to. It deliberately does not go through the Search Console service: the whole point is to answer "which account is this?" when Search Console itself is returning nothing.

func (*Identity) DescribeAccount

func (i *Identity) DescribeAccount() string

DescribeAccount renders the account for humans, saying plainly when the token cannot identify itself rather than printing an empty field.

type TokenInfo

type TokenInfo struct {
	HasToken  bool
	Expiry    time.Time
	IsExpired bool
	TokenType string
}

TokenInfo returns basic info about the stored token

func GetTokenInfo

func GetTokenInfo() (*TokenInfo, error)

GetTokenInfo returns information about the stored token

Jump to

Keyboard shortcuts

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