我正尝试使用YouTube v3 API执行使用APIKey而不是oAuth2的搜索。使用youtube v3 with apikey
我的问题是,当我使用APIKey时,查询总是返回一个错误。
这是查询
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
}];
使用APIKey时是下面的例返回错误初始化服务
_service = [[GTLServiceYouTube alloc] init];
[_service setRetryEnabled:YES];
[_service setAPIKey:kAPIKey];
代码,这个代码。如果我使用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,并且该服务已启用。
我使用了评论者的解决方案。它令我感到震惊,这是有效的。 – Morkrom 2013-11-11 08:20:48