Documentation ¶
Index ¶
- type Authenticator
- func (a Authenticator) API(ctx context.Context, token io.Reader) (*GmailAPI, error)
- func (a Authenticator) AuthURL(redirectURL string) string
- func (a Authenticator) CacheToken(ctx context.Context, authCode string, token io.Writer) error
- func (a Authenticator) Service(ctx context.Context, token io.Reader) (*gmail.Service, error)
- type GmailAPI
- func (g *GmailAPI) AddFilters(fs filter.Filters) error
- func (g *GmailAPI) AddLabels(lbs label.Labels) error
- func (g *GmailAPI) DeleteFilters(ids []string) error
- func (g *GmailAPI) DeleteLabels(ids []string) error
- func (g *GmailAPI) ListFilters() (filter.Filters, error)
- func (g *GmailAPI) ListLabels() (label.Labels, error)
- func (g *GmailAPI) UpdateLabels(lbs label.Labels) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct { State string // contains filtered or unexported fields }
Authenticator encapsulates authentication operations for Gmail APIs.
func NewAuthenticator ¶
func NewAuthenticator(credentials io.Reader) (*Authenticator, error)
NewAuthenticator creates an Authenticator instance from credentials JSON file contents.
Credentials can be obtained by creating a new OAuth client ID at the Google API console https://console.developers.google.com/apis/credentials.
func (Authenticator) API ¶
API creates a GmailAPI instance from a token JSON file contents.
If no token is available, AuthURL and CacheToken can be used to obtain one.
func (Authenticator) AuthURL ¶
func (a Authenticator) AuthURL(redirectURL string) string
AuthURL returns the URL the user has to visit to authorize the application and obtain an auth code.
func (Authenticator) CacheToken ¶
CacheToken creates and caches a token JSON file from an auth code.
The token can be subsequently used to authorize a GmailAPI instance.
type GmailAPI ¶
type GmailAPI struct {
// contains filtered or unexported fields
}
GmailAPI is a wrapper around the Gmail APIs.
func NewFromService ¶
func NewFromService(s *gmail.Service) *GmailAPI
NewFromService creates a new GmailAPI instance from the given Gmail service.
func NewWithAPIKey ¶
NewWithAPIKey creates a new GmailAPI instance from the given Gmail service and API key.
func (*GmailAPI) AddFilters ¶
AddFilters creates the given filters.
func (*GmailAPI) DeleteFilters ¶
DeleteFilters deletes all the given filter IDs.
func (*GmailAPI) DeleteLabels ¶
DeleteLabels deletes all the given label IDs.
func (*GmailAPI) ListFilters ¶
ListFilters returns the list of Gmail filters in the settings.
func (*GmailAPI) ListLabels ¶
ListLabels lists the user labels.