gcal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gcal is a minimal Google Calendar API client using only the standard library: OAuth2 refresh-token auth, free/busy queries, and event creation with Google Meet conference links. Use the Login helper (or `anvil gcal-login`) once to obtain a refresh token for a Desktop-app OAuth client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(ctx context.Context, clientID, clientSecret string, openURL func(string)) (string, error)

Login runs the OAuth2 installed-app loopback flow: starts a localhost listener, prints the consent URL, exchanges the code, and returns the refresh token. Use once per account, then store the token in config.

Types

type Client

type Client struct {
	ClientID     string
	ClientSecret string
	RefreshToken string
	HTTP         *http.Client

	// Overridable in tests; defaults to the real Google endpoints.
	TokenURL string
	APIBase  string
	// contains filtered or unexported fields
}

Client calls the Google Calendar API for one account.

func (*Client) Busy

func (c *Client) Busy(calendarID string, window interval.Span) (interval.Set, error)

Busy queries free/busy for one calendar ("primary" or an address).

func (*Client) CreateEvent

func (c *Client) CreateEvent(calendarID string, ev ics.Event, meet bool) (*Created, error)

CreateEvent inserts an event. With meet true, Google attaches a Meet conference and the link is returned; attendees receive invitations (sendUpdates=all).

func (*Client) Events

func (c *Client) Events(calendarID string, window interval.Span) (*ics.Calendar, error)

Events lists concrete event instances (recurrence pre-expanded by the API) overlapping the window, mapped into an ics.Calendar so agendas can treat every source alike.

type Created

type Created struct {
	ID       string
	HTMLLink string
	MeetLink string
}

Created describes the event made by CreateEvent.

Jump to

Keyboard shortcuts

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