oauth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package oauth provides OAuth2 authentication flows for Gmail.

Index

Constants

This section is empty.

Variables

View Source
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).

View Source
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

func NewManager(clientSecretsPath, tokensDir string, logger *slog.Logger) (*Manager, error)

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

func (m *Manager) Authorize(ctx context.Context, email string, headless bool) error

Authorize performs the OAuth flow for a new account. If headless is true, uses device code flow; otherwise opens browser.

func (*Manager) DeleteToken

func (m *Manager) DeleteToken(email string) error

DeleteToken removes the token file for the given email.

func (*Manager) HasToken

func (m *Manager) HasToken(email string) bool

HasToken checks if a token exists for the given email.

func (*Manager) TokenPath

func (m *Manager) TokenPath(email string) string

TokenPath returns the path to the token file for an email (for external use).

func (*Manager) TokenSource

func (m *Manager) TokenSource(ctx context.Context, email string) (oauth2.TokenSource, error)

TokenSource returns a token source for the given email. If a valid token exists, it will be reused and auto-refreshed.

Jump to

Keyboard shortcuts

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