YouTube API 密钥 [英] Youtube API Key

查看:163
本文介绍了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 KEY 从我的 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天全站免登陆