The google api project for my app contains a simple android key with two applications allowed. one is the com.examples.youtubeapidemo, the other is my app. If I take the com.examples.youtubeapidemo in and out of the key it fails as expected. The other app always returns this response:
11-06 08:06:52.321 32579-528/com.wfs.android.youtubesearchtest E/com.wfs.android.youtubesearchtest﹕ 403 Forbidden { "code" : 403, "errors" : [ { "domain" : "usageLimits", "message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project.", "reason" : "accessNotConfigured" } ], "message" : "Access Not Configured. Please use Google Developers Console to activate the API for your project." }
my code is this: [in an async task]
{
YouTube.Builder builder = new YouTube.Builder(
new NetHttpTransport(),
new JacksonFactory(),
new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request)
throws IOException {
}
})
.setApplicationName((String.valueOf(R.string.app_name)));
return builder.build();
}
and this:
{
// ...
YouTube youTube = createYouTubeService();
YouTube.Search.List search = null;
try {
search = youTube.search().list("id,snippet");
} catch (IOException e) {
Log.e(TAG, e.getMessage());
return null;
}
search.setKey(Developerkey.DEVELOPER_KEY);
search.setQ(q[0]);
search.setType("video");
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
SearchListResponse searchListResponse = null;
try {
searchListResponse = search.execute();
}
The exception is thrown in searchListResponse = search.execute();
I have tested the key, is there anything I may have missed in the code?
I also tested with a browser key and the com.examples.youtubeapidemo works with either one. My app still has the same issue; So all the posts about using a browser key instead did not work for me.