gmail

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package gmail implements a Gmail notification source using the Gmail API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAvailablePort

func FindAvailablePort() (int, error)

FindAvailablePort finds an available TCP port on localhost.

func New

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

func (*Source) Type

func (s *Source) Type() string

func (*Source) Validate

func (s *Source) Validate(ctx context.Context) error

Validate checks if the OAuth2 tokens are valid.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
}

TokenResponse represents the OAuth2 token exchange response.

Jump to

Keyboard shortcuts

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