Skip to content

Use freebusy.query for availability instead of events.list #274

Description

@McCal-Codes

api/schedule/availability.js checks the owner's calendar with events.list and authenticates with the calendar.readonly scope. Google's purpose-built endpoint for this is freebusy.query.

Why it is worth switching:

  • Least privilege. calendar.readonly permits downloading any calendar in full. calendar.freebusy returns only busy blocks. A leaked token would then reveal when Caleb is busy, not what with, who the attendees are, or what the events are called. Google's guidance is to choose the most narrowly focused scope available.
  • Less data over the wire. events.list returns whole event objects that get reduced to start and end times anyway.
  • Correctness. freebusy.query handles recurring events, declined invitations and all-day events the way Google itself does, rather than relying on the local expansion in getBusyTimes.

The scope and the endpoint have to change together: setting calendar.freebusy while still calling events.list returns 403 and takes availability down.

Related: #273 narrowed book.js from the full calendar scope to calendar.events for the same reason. availability.js was deliberately left alone there because it needs this endpoint change first.

Not urgent. Google Calendar credentials are not configured in production yet, so this route currently takes its no-credentials path and reads booked slots from Supabase instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions