This seems like a basic procedure but I don't know what's going wrong.
Error in logcat output:
com.google.api.client.googleapis.json.GoogleJsonResponseException:
403 Forbidden
{
"code" : 403, 02-26
"errors" : [ {
"domain" : "usageLimits",
"message" : "Access Not Configured",
"reason" : "accessNotConfigured"
}
"message" : "Access Not Configured"
I configured in the code.google.com API console the YouTube data API and got a simple access API key for my Android app.
The code is below; the same as the sample code for search:
YouTube youTube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY,
new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest httpRequest) throws IOException {}
})
.setApplicationName("youtubeplayer")
.setYouTubeRequestInitializer(new YouTubeRequestInitializer(DEV_KEY))
.build();
YouTube.Search.List search = youTube.search().list("id,snippet");
//search.setKey(DEV_KEY);
search.setQ(videoName);
search.setType("video");
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
search.setMaxResults(NUMBER_OF_VIDEO);
SearchListResponse searchListResponse = search.execute();
List<SearchResult> searchResultList = searchListResponse.getItems();
This is for Android. I can play videos with the YouTube Android player API, using the same key.