1

I'm creating a website that makes use of the google calendar events API.

If I go to: https://developers.google.com/google-apps/calendar/v3/reference/events/list I can retrieve the events without any problem.

When I try to use GET https://www.googleapis.com/calendar/v3/calendars/myacc-3483%40pages.plusgoogle.com/events?key={YOUR_API_KEY} it's not working.

I registered an app in the google developer center

API key AIzaSyDvAwN5oqjCvdYZvfPeW0mUrfzyBn9KmrI
Referers    http://www.*****.be/
Activation date Jan 5, 2014 5:02 AM
Activated by     *****

I'm using my e-mail adress as the CalendarID (which is working on the above website) and I'm making a request from my domain:

var url = 'https://www.googleapis.com/calendar/v3/calendars/myacc-3483%40pages.plusgoogle.com/events?key=AIzaSyDvAwN5oqjCvdYZvfPeW0mUrfzyBn9KmrI';

$.ajax({
    url: url,
    type: 'get',
    success: function(data) {
        alert(data);
    }
});

Console output: GET https://www.googleapis.com/calendar/v3/calendars/myacc-3483%40pages.plusgoogle.com/events?key=AIzaSyDvAwN5oqjCvdYZvfPeW0mUrfzyBn9KmrI 403 (Forbidden)

I'm not sure what I'm doing wrong, everything seems to be correct..

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Dieterg
  • 16,118
  • 3
  • 30
  • 49

2 Answers2

1

It looks like you might not be setting up authorization correctly. Below are some answers with examples on how to correctly setup Google APIs Client Library for JavaScript.

Also, possibly relevant:

Community
  • 1
  • 1
JSuar
  • 21,056
  • 4
  • 39
  • 83
0

In simple terms, your ajax call is missing an Authorization header, which looks like

Authorization: Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

Where "0b79bab50daca910b000d4f1a2b675d604257e42" is an access token. How you get an access token is non-trivial. Start with https://developers.google.com/accounts/docs/OAuth2

pinoyyid
  • 21,499
  • 14
  • 64
  • 115