Documentation
¶
Overview ¶
Package oauth provides OAuth2 authentication flows for Gmail.
Index ¶
- Variables
- type Manager
- func (m *Manager) Authorize(ctx context.Context, email string, headless bool) error
- func (m *Manager) DeleteToken(email string) error
- func (m *Manager) HasToken(email string) bool
- func (m *Manager) TokenPath(email string) string
- func (m *Manager) TokenSource(ctx context.Context, email string) (oauth2.TokenSource, error)
Constants ¶
This section is empty.
Variables ¶
var Scopes = []string{
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.modify",
}
Scopes for normal msgvault operations (sync, search, read).
var ScopesDeletion = []string{
"https://mail.google.com/",
}
ScopesDeletion includes full access required for batchDelete API. gmail.modify supports trash/untrash but NOT batchDelete.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles OAuth2 token acquisition and storage.
func NewManager ¶
NewManager creates an OAuth manager from client secrets.
func NewManagerWithScopes ¶
func NewManagerWithScopes(clientSecretsPath, tokensDir string, logger *slog.Logger, scopes []string) (*Manager, error)
NewManagerWithScopes creates an OAuth manager with custom scopes.
func (*Manager) Authorize ¶
Authorize performs the OAuth flow for a new account. If headless is true, uses device code flow; otherwise opens browser.
func (*Manager) DeleteToken ¶
DeleteToken removes the token file for the given email.
func (*Manager) TokenPath ¶
TokenPath returns the path to the token file for an email (for external use).
func (*Manager) TokenSource ¶
TokenSource returns a token source for the given email. If a valid token exists, it will be reused and auto-refreshed.