ios - 使用带有 apikey 的 youtube v3

标签 ios objective-c youtube-api api-key

我正在尝试使用 YouTube v3 API 通过 APIKey 而不是 oAuth2 来执行搜索。

我的问题是,当我使用 APIKey 时,查询总是返回错误。

这是初始化服务的代码

_service = [[GTLServiceYouTube alloc] init];
[_service setRetryEnabled:YES];
[_service setAPIKey:kAPIKey];

这是查询的代码

GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:@"snippet"];
query.q = filter;
query.type = type;
query.maxResults = maxResults;

[_service executeQuery:query completionHandler:
 ^(GTLServiceTicket *ticket, GTLYouTubeSearchListResponse *searchListResponse, NSError *error)
{
//-- do stuff
 }];

使用API​​Key时返回的错误如下。如果我使用 oAuth,一切都会按预期进行。

error: Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "The operation couldn’t be completed. (Access Not Configured)" UserInfo=0x13d10ac0 {error=Access Not Configured, GTLStructuredError=GTLErrorObject 0x13d0c770: {message:"Access Not Configured" code:403 data:[1]}, NSLocalizedFailureReason=(Access Not Configured)}

我已在 Google API 控制台上创建了 APIKey 并启用了该服务。

最佳答案

不是理想的解决方案...但我在这篇文章中找到了解决方法: google-youtube-api-v3-ios-app-key-403-error-code

基本上,如果我们使用“浏览器应用程序 key ”而不是“iOS 应用程序 key ”,它就会起作用。

关于ios - 使用带有 apikey 的 youtube v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15422722/

相关文章:

php - 让用户将视频从我的站点服务器上传到他们的 youtube channel

c++ - 用 C++ 将视频上传到 ScreenCast.com

ios - 未找到 React Native Xcode 头文件! RCT桥模块

ios - 在 OpenGLES 中组合多个着色器

ios - 如何从另一个类访问实例

objective-c - 如何在 Objective-C 中获取用户的语言环境?

ios - 如何在 objective-c 中从APNS反馈服务器接收数据

angular - 即使在全局对象上定义,Angular2 上的 onYouTubeIframeAPIReady 也找不到名称 'YT'

ios - 内部测试器单选按钮未在 iTunes Connect 中显示

ios - 如何将来自 Web 服务的数据与 Core Data 同步?