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

问题描述

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

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

在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密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:46