anu
anu

Reputation: 1106

FullCalendar: Display events from PUBLIC google calendars (say US holidays) without an API key

My website provided users with the capability to provide their own gcal feed url that I was displaying using full calendar along with the events they had created

calendarUrl = "link to public calendar url"

$('#calendar').fullCalendar({
    eventSources: [      
        {
          url: calendarUrl               
        },
        {
          url: "/user-events"
        }      
    ]    
});

Now of course this does not work. This requires a googleCalendarApiKey now. I do not expect users who are not tech savvy to create a project using Google Developer Console and provide an API key. Also how do I display events from public calendars like US holidays. How do I get the Api key for that calendar.

Seems like there should be a way to display events from PUBLIC google calendars without an API key.

Upvotes: 0

Views: 1391

Answers (2)

Roman K
Roman K

Reputation: 404

Here is what worked for me:

eventSource = {
    googleCalendarApiKey:'xxx',
    url: 'https://www.googleapis.com/calendar/v3/calendars/usa__en%40holiday.calendar.google.com/events?key=xxx',
    className: 'gcal-event', // an option!
    currentTimezone: 'America/Chicago' // an option!
  }

Upvotes: 1

anu
anu

Reputation: 1106

Found answer at How to Define which Calendar to Connect to using Google Calendar API v3 Service

You need your own key to display any public calendar - not their key!! I found that a key for server applications worked for me not a key for browsers.

$('#calendar').fullCalendar({
  googleCalendarApiKey: "<key for server apps>",
  eventSources: [      
    {
      googleCalendarId: "email of public calendar"               
    }      
  ]    
});

Upvotes: 0

Related Questions