WoJ
WoJ

Reputation: 30035

What does a 404 mean in the context of a Google Calendar API?

I am trying to programatically access a calendar I own using the Google Calendar API list:

r = requests.get(
        url="https://www.googleapis.com/calendar/v3/calendars/<the ID of my calendar which looks like [email protected]>/events",
        params={
            'key': <the key from the API console>,
            'singleEvents': True,
            'orderBy': 'startTime'
        }

This call fails with a 404:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

What does that error actually mean, in the context of this API?

Note:

Upvotes: 1

Views: 2741

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117186

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

Can mean one of two things. Either the calendar Id you have typed is in correct or the user who you are authenticated with does not have access to that calendar. Make sure you are logging in with the correct user with access to that calendar. Optionally you can do a calendar.list which will return a list of the calendars that the user currently has access to. That way you wont have to worry about possibly miss typing the calendar id.

authorization

The method you are using events.list requires authorization (permission from the user) in order to access their calendar. Which can be seen in the documentation page

enter image description here

You need to authncate your user using Oauth2 and one of the scopes above. You will then have an access token you can use to access this calendar.

apikey

Api keys are used for accessing public data. Unless your calendar is set to public you will not be able to use it to see events. Also remember that api keys do not have access to update public calendars you still need to be authenticated to make changes to them.

Service account

If this is a server to server application you should use a service account not an API key. All you need to do is add the service account as a user on the google calendar like you would any other user. It will then have access to your calendar.

Upvotes: 3

Related Questions