【发布时间】:2014-02-26 11:36:32
【问题描述】:
我正在尝试将观看 YouTube 中某些视频的功能添加到我正在创建的 iOS 应用中。正如 cmets 所建议的那样,我有一个来自 Google 的 API 密钥并已从开发者控制台启用了 YouTube API。这不是问题。
我有一个非常简单的方法,可以从其 ID 中收集特定 YouTube 频道的详细信息,然后我将使用它来查找所有这些频道上传的视频。我遇到的问题是它说我的访问权限未配置。这是我所做的一切:
获取信息的方法(显然我没有在其中包含我的密钥或频道 ID):
- (void)collectChannelData {
GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
service.APIKey = @"API_KEY";
GTLQueryYouTube *query = [GTLQueryYouTube queryForChannelsListWithPart:@"contentDetails"];
query.channelId = @"CHANNEL_ID";
GTLServiceTicket *ticket = [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
if (!error) {
GTLYouTubeChannelListResponse *channelItem = object;
NSLog(@"%@", channelItem);
} else {
NSLog(@"%@", error);
}
}]; }
我已确保 YouTube 数据 API v3 已在 Google 开发者控制台中打开,并且 Bundle Identifier 与我的 Info.plist 中的内容相匹配
我收到的错误信息是:
Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "无法完成操作。(访问未配置。请使用 Google Developers Console 为您的项目激活 API。)" UserInfo=0xa3aa0e0 {error=Access未配置。请使用 Google Developers Console 为您的项目激活 API。GTLStructuredError=GTLErrorObject 0x8a74630: {message:"Access Not Configured. Please use Google Developers Console to activate the API for your project., GTLStructuredError=GTLErrorObject 0x8a74630: {message:"Access Not Configured. Please use Google Developers Console to activate the API for your project." code:403 data:[1]}, NSLocalizedFailureReason=(访问未配置。请使用 Google Developers Console 为您的项目激活 API。)}
我找不到任何原因导致这不起作用。我相信我是正确的,因为我不需要为此特定请求设置结算帐户或需要 oAuth。我还可以在 Developer Console 上的应用程序概述中看到已收到多个请求,但每个请求都有一个错误。我只是想不通它为什么拒绝它。
感谢您的帮助。
【问题讨论】:
-
谢谢你,花了一些时间才找到这个。我在使用 Translate API 时遇到了同样的问题。
标签: ios youtube-api