【发布时间】:2016-01-20 08:17:01
【问题描述】:
我在让 Google 云端点与我的 javascript 客户端中的 YouTube 数据 API v3 协同工作时遇到问题。我认为我的问题在于 gapi.client.setApiKey() 方法为我的端点 API 和 YouTube api 设置密钥。当我设置密钥 YouTube 工作但我的端点没有,我使用我的端点 API 看到以下错误:
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. The API () is not enabled for your project. Please use the Google
Developers Console to update your configuration.",
"extendedHelp": "https://console.developers.google.com"
}
如果没有密钥,我的端点可以工作,但 youtube 搜索不能,我使用搜索功能收到此消息:
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
加载 API 的代码总结如下,但基本上我遵循了端点 python/javascript 教程和 youtube 数据 API 教程!
init = function(apiRoot) {
var apisToLoad;
var callback = function(){
if(--apisToLoad == 0){
enableButtons();
}
}
apisToLoad = 2; // must match number of calls to gapi.client.load()
gapi.client.load('myAPIName', 'v1', callback, apiRoot);
gapi.client.load('youtube', 'v3', onYouTubeApiLoad);
};
// Called automatically when YouTube API interface is loaded (see line 9).
function onYouTubeApiLoad() {
//sets the api key
gapi.client.setApiKey('APIKeyForYouTubeFromDevConsole');
}
【问题讨论】:
-
你能在你的处理程序在这里做的事情中提供更多的代码吗?我知道可以做到,而且我知道对端点和 youtube 使用相同的密钥是错误的,但是如果没有更多代码,很难告诉您需要更改的内容
-
更新了一些代码,如果有帮助,请告诉我...我想我需要指定要为哪个 API 设置密钥,但不知道该怎么做?谢谢!
标签: javascript python google-cloud-endpoints google-cloud-platform youtube-data-api