在我的javascript客户机中,让Google云端点与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');
}发布于 2015-10-24 20:19:51
要验证使用API键的youtube API请求,请删除api.client.setApiKey方法调用。
在调用YouTube数据API时,向API请求添加一个关键参数:
var request = gapi.client.youtube.search.list({
part: 'snippet',
type: 'video',
maxResults: 12,
q: searchValue,
key: 'YourAPIKeyGoesHere'
});这意味着只有这些API调用是授权的,而不是端点调用。
发布于 2015-10-23 18:53:06
我对Youtube数据API并不十分熟悉。但我认为您为端点使用的代码是我们提供的代码。您绝对可以将此代码用于Endpoints。关于Youtube的数据,我建议使用看这里。
看起来您需要的代码如下所示:
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.services.youtube.YouTube;
public class myClass {
/**
* Define a global instance of a Youtube object, which will be used
* to make YouTube Data API requests.
*/
private static YouTube youtube;
public static void main(String[] args) {
List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube");
try {
// Authorize the request.
Credential credential = Auth.authorize(scopes, "invideoprogramming");
// This object is used to make YouTube Data API requests.
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential)
.setApplicationName([YOUR APP])
.build();
}在那里,您应该能够使用youtube对象进行调用,而gapi则可以将内容发送到您的端点。
https://stackoverflow.com/questions/33257532
复制相似问题