Streaming API 401 Bad Auth Error, Where is the bug?

streaming
python

#1

So I decided to implement my own OAuth because Tweepy kept crashing and I need a constant stream of data for my Dissertation for Uni. I get a 401 Auth error but not sure why. It’s probably something trivial and simple.

I am not sure what I should post but I will post the Python code and my response. Here is the response I get.

https://stream.twitter.com/1.1/statuses/filter.json?track=Tesla&track=%23Tesla&track=%24TSLA&track=%23gigafactory&track=gigafactory&track=giga+factory&language=en

<Response [401]>
<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n<title>Error 401 Unauthorized</title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing '/1.1/statuses/filter.json?track=Tesla&amp;track=%23Tesla&amp;track=%24TSLA&amp;track=%23gigafactory&amp;track=gigafactory&amp;track=giga+factory&amp;language=en'. Reason:
<pre>    Unauthorized</pre>
</body>
</html>

And here is my Python code:
http://pastebin.com/pwMdknuj

I think I have compiled the Auth string right, can you see a problem in it?

Thanks for the help.


#2

I can successfully connect to the stream using twurl. You may find it helpful to compare the header generated by twurl (you can see it by using the -t flag).

e.g.

$ twurl -t -H stream.twitter.com -A "Accept-encoding: none" -t -d "track=Tesla" -X POST "/1.1/statuses/filter.json"