I am using youtube api to get contents from a youtube account (with just user feed...without user authentication) on our website. Since yesterday morning, we keep getting:
I had the same problem with Youtube API + App-Engine. I was passing the developer-key as parameter of the request, as well as the other suggested parameters (user-ip, developer-key in the request url) and still didn't work with App Engine.
Well it seemed that the developer key wasn't getting through (although X-Gdata-key was present in the POST request headers). I've found this solution:
Every YouTubeService instance has the attributes developer_key and client_id. Setting this attributes when creating the service instance (instead of setting the 'X-GData-Key' in the headers or the key attribute of a query instance) makes the developer_key for the app id: client_id to be sent in every request, and accepted successfully.
You can set these values in the constructor of YouTubeService for the Java API.
If you are using the API for Python, you can set the parameters directly as following:
client = gdata.youtube.service.YouTubeService()
client.client_id = <application_id>
client.developer_key = <developer_key>
I noticed that my developer_key wasn't getting through by checking the stats on the YouTube API dashboard.
While re-building the wheel for youtube api with python, I found what might have caused the X-GData-Key
unrecognizable. This answers @Javierfdr .
Short answer: urllib2
is doing .capitalize()
and .title()
all over and mess up the headers.
There are bunch of those code all over in the urllib2
module. Some in handlers and some in Request
. X-GData-Key
is converted into X-Gdata-Key
(titled, note the lower d), or X-gdata-key
(when capitalized). I had to build a custom HTTPSHandler and a Request object just to comment out the lines.
I'm not sure why they do this, but a long thread talks about this issue in http://bugs.python.org/issue2275 . I guess it didn't make it to python 2.7.
I tried out the requests library, and it didn't mess up it with headers. Hooray :)
Just so that others would not waste their time, or at least have a clue what's happening.
-- edit --
Actually, I found out the RFC states the header field names are case-insensitive, and I couldn't find out any evidence that google doesn't. I was wrong about the statement below, I still don't get any stats :( Sorry to be misleading.
After changing all of them, I finally saw the stats in YouTube API dashboard - always wondered why there was no data until now.