Documentation
¶
Overview ¶
Package gmail implements a Gmail notification source using the Gmail API.
Index ¶
- func FindAvailablePort() (int, error)
- func New(cfg notifysource.Config, tokens notifysource.TokenAccessor) (notifysource.Source, error)
- type OAuth2Manager
- func (m *OAuth2Manager) CompleteAuthFlow(ctx context.Context, state, code, clientID, clientSecret string) (*PendingAuth, *TokenResponse, error)
- func (m *OAuth2Manager) PeekPending(state string) *PendingAuth
- func (m *OAuth2Manager) StartAuthFlow(clientID, agentID, sourceID, redirectURI string) (string, error)
- type PendingAuth
- type Source
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAvailablePort ¶
FindAvailablePort finds an available TCP port on localhost.
func New ¶
func New(cfg notifysource.Config, tokens notifysource.TokenAccessor) (notifysource.Source, error)
New creates a new Gmail notification source.
Types ¶
type OAuth2Manager ¶
type OAuth2Manager struct {
// contains filtered or unexported fields
}
OAuth2Manager manages OAuth2 authorization flows for Gmail.
func NewOAuth2Manager ¶
func NewOAuth2Manager() *OAuth2Manager
NewOAuth2Manager creates a new OAuth2 manager.
func (*OAuth2Manager) CompleteAuthFlow ¶
func (m *OAuth2Manager) CompleteAuthFlow(ctx context.Context, state, code, clientID, clientSecret string) (*PendingAuth, *TokenResponse, error)
CompleteAuthFlow exchanges the authorization code for tokens. Returns the PendingAuth (for agent/source binding) and the token response.
func (*OAuth2Manager) PeekPending ¶
func (m *OAuth2Manager) PeekPending(state string) *PendingAuth
PeekPending returns the pending auth for a state without consuming it.
func (*OAuth2Manager) StartAuthFlow ¶
func (m *OAuth2Manager) StartAuthFlow(clientID, agentID, sourceID, redirectURI string) (string, error)
StartAuthFlow begins an OAuth2 authorization flow and returns the URL to redirect the user to.
type PendingAuth ¶
type PendingAuth struct {
AgentID string
SourceID string
State string
CodeVerifier string
RedirectURI string
CreatedAt time.Time
}
PendingAuth tracks an in-progress OAuth2 authorization flow.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source implements notifysource.Source for Gmail.
func (*Source) Poll ¶
func (s *Source) Poll(ctx context.Context, cursor string) (*notifysource.PollResult, error)
Poll checks for new emails since the given cursor (Gmail historyId).