【发布时间】:2014-11-17 21:42:36
【问题描述】:
我正在尝试使用 v3 的 Google API 从客户的公共日历中获取事件列表。我在API Explorer 中输入了日历 ID,我得到了肯定的结果:
https://www.googleapis.com/calendar/v3/calendars/rpsj44u6koirtq5hehkt21qs6k%40group.calendar.google.com/events?key={YOUR_API_KEY}`
=> [List of events here, as expected]
为了创建 API 密钥,我在 Google Developer Console 中创建了一个项目,创建了一个公共 API 访问密钥(APIs & auth > Credentials),并将上面的 {YOUR_API_KEY} 替换为我的实际密钥.我确保日历 API 已打开(APIs & auth > APIs)。当我将此 URL 粘贴到浏览器中时,我收到以下错误响应:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration."
}
}
我看到的所有回复都说您需要确保 Google 日历 API 已打开,而且肯定是打开的(此外,默认情况下已打开)。我在这里错过了什么?
【问题讨论】:
-
我刚刚在 API 控制台中创建了一个全新的项目,单击日历 API 旁边 API 部分中的小开关,然后为服务器创建了一个新的公共 API 访问密钥凭据部分中的应用程序。然后我进入浏览器,粘贴googleapis.com/calendar/v3/calendars/…>,一切正常,所以你的步骤中一定只有一个小错误;)
-
您找到解决方案了吗?我正在经历同样的事情
-
我最好的猜测是,您需要从您在开发者控制台(APIs & Auth > Credentials > Referers)中输入“Referers”字段的同一服务器进行 API 调用。我从我设置的本地站点打了一个电话(我将
localhost:8888/*放在了引用字段中),它现在正在返回日历事件。
标签: api calendar google-api google-calendar-api