21

I'm following the tutorial on this page but I keep getting a 403 Forbidden error when I run the app and try to do a search.

I enabled Youtube Data API v3 on the https://console.developers.google.com/ page and I created an Android API key.

Any suggestions? Thank you.

Could not search: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"reason" : "ipRefererBlocked",
"extendedHelp" : "https://console.developers.google.com"
} ],
"message" : "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
kj tolentino
  • 571
  • 1
  • 4
  • 7

5 Answers5

36

I have resolved the problem by creating a Browser key instead of an android key. The browser key needs to have no entry so that it'll say "all refered allowed"

kj tolentino
  • 571
  • 1
  • 4
  • 7
  • I was also having this problem on iOS. This resolved it. – dfmuir May 05 '15 at 04:38
  • Interesting @dfmuir I only had the issue in Android, but not iOS. I wonder why this happens... – LargeGlasses May 09 '15 at 23:16
  • @LargeGlasses How did you make this work in iOS? If I use an iOS key and input my bundle identifier, it won't work. If I use a "blank bundle identifier", it says "all allowed" it works. But I don't want that.. Did you use the bundle identifier? – Sti May 23 '15 at 16:18
  • 1
    @Sti I removed the bundle identifier. I'm not sure if that will come back to haunt me later or not... – LargeGlasses May 25 '15 at 17:16
  • I was battling to find referred allowed option in Youtube Api key, but it turns out it needed to be Browser key. Thank you a lot. – fullmoon Sep 25 '15 at 16:51
  • This was the trick to use the Google API key for tvOS! Thanks! – axello Dec 07 '15 at 23:30
  • I have to add a restriction for API usage, android can access only. How can I do that? any idea? – Milon Apr 25 '17 at 16:24
2

Used this for iOS app and received same error so I removed bundle identifier and it worked

Silviu St
  • 1,810
  • 3
  • 33
  • 42
1

I have resolved the problem by creating a Server key instead of an iOS key

MK_iOS
  • 388
  • 5
  • 13
1

I had the same problem and after a lot of wasted time my hosting service figured out the API request was being generated by a different IP address than the one associated with my website.

Rob Fenwick
  • 169
  • 11
0

For anyone who finds this that couldn't solve it with the answers above, my problem was the way I entered the domain into the API restriction. I had put *.example.com/*, but my requests were coming from https://example.com. When I removed the *. at the beginning, my requests began working.

wuijin
  • 19
  • 2