Google Calendar API v3 404 for Events

2019-08-11 17:15发布

问题:

I've got a relatively simple task I'm trying to accomplish with the Google Calendar v3 API, but I keep running into 404 errors. I only need to access one calendar (belonging to my client) and get read-only event data via Javascript (just using the protocol with an Ajax call), so I'm trying to avoid using authentication.

I made the calendar public by going to the calendar sharing settings clicking "Share this calendar with others" and then choosing "Make this calendar public. However, the only option I have for public is "See only free/busy (hide details)."

Having realized that, I edited each event to specifically set the type to "public."

Now, I'm able to get a eventList from the calendar resource, but there are only a few details for each item in the array (see below). And, when I try to access the individual event, I get a 404.

Having tried with a basic test calendar, I'm fairly certain the calendar sharing settings are the issue. The main difference between my client's calendar and the test calendar I used is that his calendar is a part of a Google Apps for business account, I'm fairly certain.

Is there any setting in the calendar itself I can edit to make the API work without having to use auth to access the data? Or, is there an option in the business apps settings I can have my client change? Again, I'm talking about only doing GET requests on one specific calendar using Javascript, so authentication is undesirable.

There's really no code I can show here because I'm just grabbing the data via the URI; I have the same problem (the 404) when using the explorer tool in the API docs. However, as you might expect, when I authenticate with that explorer tool, the events appear with no problems.

Sample item from the eventList:

  {
   "kind": "calendar#event",
   "id": "(idremoved)",
   "status": "confirmed",
   "updated": "2012-05-29T21:06:42.000Z",
   "start": {
    "dateTime": "2012-06-18T19:00:00-05:00"
   },
   "end": {
    "dateTime": "2012-06-18T21:00:00-05:00"
   },
   "visibility": "public"
  }

回答1:

I'm using the following to read Google Apps for Education calendars, which has the same api and security restrictions as for Business.

After getting the public calendar address, I decided to parse the full version of the calendar instead of the basic version:

https://www.google.com/calendar/feeds/your_calendar_id_here%40gmail.com/public/full

from what I've seen if your calendar is public, your events will be as well. You will want to make sure that the public for your calendar is accessible in your browser by just pasting the url. Check that events are also public by doing that as well. Make sure that the calendar is public but the "Share only my free/busy information (Hide details)" box is unchecked