Documentation
¶
Overview ¶
Package gmail provides a bounded Gmail metadata and label transport.
Index ¶
- Constants
- Variables
- func HasModifyScope(scope string) bool
- func KeychainAvailable() bool
- func StoreCredentials(email string, credentials Credentials) error
- type API
- type Client
- func (c *Client) FindMessages(ctx context.Context, messageID string) ([]string, error)
- func (c *Client) GetMessage(ctx context.Context, id string) (Message, error)
- func (c *Client) ListLabels(ctx context.Context) ([]Label, error)
- func (c *Client) ModifyLabels(ctx context.Context, id string, add, remove []string) error
- func (c *Client) Profile(ctx context.Context) (Profile, error)
- type ClientOption
- type CredentialTokenSource
- type Credentials
- type Header
- type Label
- type Message
- type Payload
- type Profile
- type RequestError
- type TokenSource
- type TokenSourceFunc
Constants ¶
const ModifyScope = "https://www.googleapis.com/auth/gmail.modify"
Variables ¶
var ErrCredentialsNotFound = errors.New("Gmail credentials were not found in macOS Keychain; connect or explicitly import credentials")
Functions ¶
func HasModifyScope ¶
func KeychainAvailable ¶
func KeychainAvailable() bool
func StoreCredentials ¶
func StoreCredentials(email string, credentials Credentials) error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(client *http.Client, tokens TokenSource, options ...ClientOption) *Client
func (*Client) FindMessages ¶
FindMessages retrieves every page or returns no candidates and an error. A result is only a candidate: callers must verify the Message-ID header.
func (*Client) GetMessage ¶
func (*Client) ModifyLabels ¶
ModifyLabels reports HTTP acceptance only. Read metadata to verify final labels.
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
type CredentialTokenSource ¶
type CredentialTokenSource struct {
// contains filtered or unexported fields
}
func NewCredentialTokenSource ¶
func NewCredentialTokenSource(credentials Credentials, client *http.Client) *CredentialTokenSource
type Credentials ¶
type Credentials struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
RefreshToken string `json:"refresh_token"`
AccessToken string `json:"access_token,omitempty"`
Expiry time.Time `json:"expiry,omitempty"`
Scope string `json:"scope"`
}
Credentials is the explicit JSON import format. Expiry is RFC3339. Secret fields are persisted only in macOS Keychain, never a plaintext cache.
func LoadCredentials ¶
func LoadCredentials(email string) (Credentials, error)
func (Credentials) GoString ¶
func (c Credentials) GoString() string
func (Credentials) String ¶
func (c Credentials) String() string
type Profile ¶
type Profile struct {
EmailAddress string `json:"emailAddress"`
}
func Connect ¶
func Connect(ctx context.Context, clientJSONPath, expectedEmail string, openURL func(string) error, client *http.Client) (Profile, error)
Connect runs installed-client OAuth using a loopback listener, state and PKCE. openURL is supplied by the CLI and receives the consent URL, without secrets.
type RequestError ¶
RequestError never includes response bodies, bearer tokens, or request URLs. Uncertain means a mutation was dispatched and its final outcome needs a read.
func (*RequestError) Error ¶
func (e *RequestError) Error() string