YouTube API密钥 [英] Youtube API Key

查看:924
本文介绍了YouTube API密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用YouTube API进行搜索时,出现此错误:

When I try to use YouTube API for Search, I get this error:

出现服务错误:403:请求未指定任何内容 Android套件名称或签名证书指纹.请确保 客户端正在向他们发送邮件或使用API​​控制台更新您的 关键限制.

There was a service error: 403 : The request did not specify any Android package name or signing-certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions.

在MainActivity中,我有以下代码:

In the MainActivity I have this code:

youtube = new YouTube.Builder(new NetHttpTransport(), JSON_FACTORY, new HttpRequestInitializer() {
                    @Override
                    public void initialize(HttpRequest httpRequest) throws IOException {

                    }
                }).setYouTubeRequestInitializer(new YouTubeRequestInitializer(apiKey)).setApplicationName("Some Name").build();

在云控制台中,我有一个适用于Android的ApiKey,其中设置了程序包名称,并使用keytool命令获得了SHA-1编号.

In the cloud console I have an ApiKey for Android, with the package name set and the SHA-1 number obtained with keytool command.

推荐答案

经过反复试验,最终对我有用的是将 API KEY 的限制更改为从API Manager控制台中选择 Android ,然后保存即可.

After lot of trial and error, the thing which finally worked for me was changing API KEY restriction to None instead of Android from API Manager console and just save.

完成上述步骤后,我可以使用我的API密钥从我的Android设备进行搜索API调用.

After doing the above step I am able to make search API call from my Android device using my API KEY.

这篇关于YouTube API密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆