2014-01-05 106 views
1

我創建了一個使用谷歌日曆事件API的網站。谷歌日曆事件列表

如果我去:https://developers.google.com/google-apps/calendar/v3/reference/events/list 我可以檢索事件沒有任何問題。

當我嘗試使用GET https://www.googleapis.com/calendar/v3/calendars/myacc-3483%40pages.plusgoogle.com/events?key={YOUR_API_KEY}它不起作用。

我註冊了一個應用程序在谷歌開發者中心

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

我用我的電子郵件ADRESS作爲CalendarID(這是工作上面的網站),我正在從我的要求域:

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); 
    } 
}); 

控制檯輸出:GET https://www.googleapis.com/calendar/v3/calendars/myacc-3483%40pages.plusgoogle.com/events?key=AIzaSyDvAwN5oqjCvdYZvfPeW0mUrfzyBn9KmrI 403 (Forbidden)

我不知道我在做什麼錯了,一切似乎是正確的..

回答

1
+0

謝謝您的鏈接,我會在週末查看它們! – Dieterg

0

簡單來說,你的Ajax調用缺少Authorization頭,它看起來像

Authorization: Bearer 0b79bab50daca910b000d4f1a2b675d604257e42 

其中 「0b79bab50daca910b000d4f1a2b675d604257e42」 是一個訪問令牌。你如何獲得訪問令牌並不重要。開始於https://developers.google.com/accounts/docs/OAuth2