I am new to Python and I’ve been trying to connect to Twitter’s public data streams as a practice project. I’ve gotten this far:
>>> import urllib2
>>> url = urllib2.urlopen("https://stream.twitter.com/1/statuses/sample.json")
Trackback...(omitted)
urllib2.HTTPError: HTTP Error 401: Unauthorized
The 401 Error was expected, however I’m at a loss as to how to move forwards. I’m currently reading the Twitter Authentication API Docs, they recommend third party libraries, which I could do but I want to avoid because I really want to learn what is going on. I think you have to put the OAuth data in the header? Should I use add_header()?
The link you posted requires HTTP auth:
See this