Reputation: 33
I'm developing new app with this feature:
- user can search youtube videos from the app ..
I tried to use youtube api ..i created project in google console, generated api_key with android apps restriction(wrote app package & SHA-1 certificate fingerprint).
I used this link :
https://www.googleapis.com/youtube/v3/search?part=snippet&q=blabla&type=video&key=[api_key]
as I got from: https://developers.google.com/youtube/v3/docs/search/list
but unfortunately I got this response and idk why
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "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.",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=953519755004"
}
],
"code": 403,
"message": "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."
}
}
i hope any one can save my day
Upvotes: 0
Views: 457
Reputation: 141
you might need to set two request headers:
youTube = new YouTube.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(), new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { String packageName = context.getPackageName(); String SHA1 = getSHA1(packageName);
request.getHeaders().set("X-Android-Package", packageName);
request.getHeaders().set("X-Android-Cert",SHA1);
}
}).setApplicationName(appName).build();
Upvotes: 0