未经身份验证使用的每日限制超过Google Api日历 [英] Daily Limit for Unauthenticated Use Exceeded Google Api Calendar
问题描述
我正在测试示例代码。它一直有效,但我突然得到:
I'm testing a sample code. It has always worked but suddenly i get:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
同样,它始终有效。 没有任何改变。我知道设置console dev和blablabla。我想知道这个问题的原因。
Again, it has ALWAYS worked. Nothing changed. I know to set console dev stuff and blablabla. I would like to know the cause of this issue.
这是我的剧本:
gapi.client.init({
'apiKey': 'xxxxxxxx',
'discoveryDocs': ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"],
'clientId': 'xxxx.apps.googleusercontent.com',
'scope': 'https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar',
}).then(function() {
gapi.client.calendar.events.list({
'calendarId': 'primary',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 10,
'orderBy': 'startTime' //from input
}).then(function(response) {
var events = response.result.items;
if (events.length > 0) {
for (var i = 0; i < events.length; i++) {
var event = events[i];
var when = event.start.dateTime;
if (!when) {
when = event.start.date;
}
appendPre(event.summary + ' (' + when + ')created at '+ event.created);
}
} else {
appendPre('No upcoming events found.');
}
});
});
function appendPre(message) {
var pre = document.getElementById('content');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
推荐答案
即使您未进行身份验证以用户身份登录日历时,您应该创建一个客户端项目并将您的密钥附加到请求,以便Google有一个项目来计费配额使用情况。这将在未来防止这类问题。请参阅 Google的帮助文章,但一般步骤如下:
Even if you are not authenticating to Calendar as a user, you should create a client project and attach your key to requests so that Google has a project to "bill" the quota usage against. This will prevent these kind of issues in the future. See Google's help article but the general steps would be:
1)在 https:// console创建一个Google API项目。 developers.google.com 。
2)为项目启用Calendar API。
3)在API Manager> Credentials下获取API密钥。
4)包含密钥作为所有Calendar API请求的参数。例如
1) Create a Google API Project at https://console.developers.google.com. 2) Enable Calendar API for the project. 3) Get the API key under API Manager > Credentials. 4) Include the key as a parameter for all your Calendar API requests. E.g.
GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events?key={your_key}
这篇关于未经身份验证使用的每日限制超过Google Api日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!