I'm trying to get history feed from YouTube of an authenticated user with python. This is my code :
yt_service = gdata.youtube.service.YouTubeService()
def LogIn():
login_name = raw_input('Email:')
login_pass = getpass.getpass()
try:
yt_service.email = login_name
yt_service.password = login_pass
yt_service.ProgrammaticLogin()
except:
print 'False username or password. Unable to authenticate.'
exit();
def GetHistoryFeed():
uri = 'https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2'
feed = yt_service.GetYouTubeVideoFeed(uri)
#PrintVideoFeed(yt_service.GetYouTubeVideoFeed(uri),'history')
LogIn()
GetHistoryFeed()
and it says gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'} . I know I have to make a authenticated Get request , but i don't know how. What am I doing wrong ?
EDIT
I am facing a major problem. The prog is the same as above , but with yt_service.developer_key = DEVELOPER_KEY
added under password line and uri = 'https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2&key=%s'%DEVELOPER_KEY
. I tested it in 4 PCs and it runs without errors only in one if them. I get this error :
File "/usr/local/lib/python2.6/dist-packages/gdata/youtube/service.py", line 186, in
return self.Get(uri, converter=gdata.youtube.YouTubeVideoFeedFromString)
File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 1108, in Get
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'}
I use python 2.7 and gdata python 2.0 . Why one Pc executes it and the rest of them not? What can i do to fix it ? Please help!