本文介绍了Google YouTube API v3 iOS应用程序密钥,403错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新项目并开启了YouTube Data API v3。在API访问面板中,我创建了浏览器应用程序(包含查找程序)的关键字,可以正常工作。我继续为iOS应用程序创建密钥(使用包标识符)。一切看起来很好我已经检查了捆绑ID 10次,我相信它是正确的。但是,如果我继续使用iOS API密钥从iOS应用程序创建NSURLRequest,则会收到错误响应:

  error = {
code = 403;
errors =(
{
domain = usageLimits;
message =Access Not Configured;
reason = accessNotConfigured;
}
) ;
message =访问未配置;
};



$ b $ p
$ b

使用相同的url只传递我的密钥用于浏览器应用程序(与引用程序)任何问题。

  NSString * string = [NSString stringWithFormat:@https://www.googleapis.com/youtube/v3/videos? ID = 7lCDEYXw3mM&安培;键=%@&安培;字段=项(ID,片段(的channelID,标题,的categoryId),统计(观看次数))及部分=片断,统计,键]。 

我真的很困惑这里有什么问题,我一直试图让它工作iOS应用程序现在关键小时。是否有什么明显的缺失?

解决方案

如果您从任何应用程序(iOS或其他)发出原始HTTP请求,您可以将包含为 key = URL参数,它应该足够了(至少对于只读,未经过验证的调用) p>

I have created a new project and turned on YouTube Data API v3. In API access pane I have Key for browser apps (with referers) created, witch works fine. I went ahead and created Key for iOS apps (with bundle identifiers). Everything looks well I have checked the bundle id 10 times, I am sure it is correct. However if I go ahead and create NSURLRequest from my iOS app using iOS API key I get error response:

error =     {
    code = 403;
    errors =         (
                    {
            domain = usageLimits;
            message = "Access Not Configured";
            reason = accessNotConfigured;
        }
    );
    message = "Access Not Configured";
};
}

Using same url only passing my Key for browser apps (with referers) work without any issues.

NSString *string=[NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=%@&fields=items(id,snippet(channelId,title,categoryId),statistics(viewCount))&part=snippet,statistics",key];

I am really puzzled on what is the problem here, I have been trying to get it to work with iOS app Key hours now. Is there something obvious Im missing ?

解决方案

If you're making raw HTTP requests from any application (iOS or otherwise), then you can include the "key for browser apps" as the key= URL parameter and it should be sufficient (at least for read-only, non-authenticated calls).

这篇关于Google YouTube API v3 iOS应用程序密钥,403错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:12