访问未配置.请使用Google Developers Console为youtube搜索列表激活项目的API

Ani*_*tel 3 youtube android youtube-data-api

我从Youtube搜索列表实现youtube搜索列表

但是出现了这个错误

访问未配置.请使用Google Developers Console激活项目的API

码:-

youtube = new YouTube.Builder(transport,jsonFactory, new HttpRequestInitializer() 
{
    @Override
    public void initialize(HttpRequest request) throws IOException {
    }
}).setApplicationName("youtube-cmdline-search-sample").build();


String queryTerm = getInputQuery();

// Define the API request for retrieving search results.
YouTube.Search.List search = youtube.search().list("id,snippet");

// Set your developer key from the Google Developers Console for

String apiKey = ""; //i have server key and browser key
search.setKey(apiKey);
search.setQ(queryTerm);

search.setType("video");

search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Ani*_*tel 11

解:-

我从这里的老开发者控制台站点创建了项目.

我使用了Old开发者控制台站点的浏览器密钥.