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



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.

<Response [401]>
<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n<title>Error 401 Unauthorized</title>
<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>

And here is my Python code:

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

Thanks for the help.


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).


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