auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultScopes = []string{

	"ZohoMail.messages.ALL",
	"ZohoMail.folders.ALL",
	"ZohoMail.tags.ALL",
	"ZohoMail.accounts.ALL",

	"ZohoMail.organization.accounts.ALL",
	"ZohoMail.organization.domains.ALL",
	"ZohoMail.organization.groups.ALL",
	"ZohoMail.organization.spam.ALL",
	"ZohoMail.organization.policy.ALL",
	"ZohoMail.organization.audit.READ",
}

DefaultScopes defines the OAuth2 scopes required for v1 functionality. Zoho uses comma-separated scopes (not space-separated like standard OAuth2). Scope reference: https://www.zoho.com/mail/help/api/

Functions

func InteractiveLogin

func InteractiveLogin(ctx context.Context, cfg *config.Config) (*oauth2.Token, error)

InteractiveLogin performs an OAuth2 login flow using the browser. Opens the authorization URL in the default browser and starts a local callback server.

func ManualLogin

func ManualLogin(ctx context.Context, cfg *config.Config) (*oauth2.Token, error)

ManualLogin performs an OAuth2 login flow by printing the auth URL and accepting a pasted redirect. This is useful for environments where the browser can't be opened automatically (SSH, headless, etc).

func ScopeString

func ScopeString() string

ScopeString returns scopes as a comma-separated string. Zoho requires comma separator, not the space separator used by standard OAuth2.

Types

type TokenCache

type TokenCache struct {
	// contains filtered or unexported fields
}

TokenCache implements oauth2.TokenSource with file-based caching and file locking. It prevents concurrent refresh stampede and auto-refreshes tokens proactively.

func NewTokenCache

func NewTokenCache(cfg *config.Config, store secrets.Store) (*TokenCache, error)

NewTokenCache creates a new token cache for the given configuration.

func (*TokenCache) ClearTokens

func (tc *TokenCache) ClearTokens() error

ClearTokens removes all stored tokens (used by logout).

func (*TokenCache) SaveInitialTokens

func (tc *TokenCache) SaveInitialTokens(token *oauth2.Token) error

SaveInitialTokens stores the tokens from a successful login. This should be called after InteractiveLogin or ManualLogin completes.

func (*TokenCache) Token

func (tc *TokenCache) Token() (*oauth2.Token, error)

Token implements oauth2.TokenSource.Token(). Returns a valid access token, refreshing if necessary.

Jump to

Keyboard shortcuts

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