Twitter Streaming Unauthorized


#1

I have built a Twitter library for getting data from twitter apis. The REST APIs are working fine. I am getting a 401 unauthorized error for Public Streams by location. Here are the error details:

Transfer-Encoding: chunked
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html
WWW-Authenticate: OAuth realm=“Firehose”

The api I am accessing is : https://stream.twitter.com/1.1/statuses/filter.json?locations=34.54899790,16.3795280,55.66669990,32.1542840

Here is my code:

                Uri =  https://stream.twitter.com/1.1/statuses/filter.json?locations=34.54899790,16.3795280,55.66669990,32.1542840
                System.Uri APIUrl = new System.Uri(Uri);
                //The Header builder generates the signature as well.
                UriHeader = APIHelper.RequestHeaderBuilder(Credentials, APIUrl);
                //Generate Web Request & Request Header
                HttpWebRequest webRequest = null;
                webRequest = (HttpWebRequest)System.Net.WebRequest.Create(APIUrl);
                webRequest.Method = "GET";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Headers.Add("Authorization", UriHeader);
                webRequest.Host = "stream.twitter.com";
               
                    HttpWebResponse TwitterResponse = (HttpWebResponse)webRequest.GetResponse();
                    using (StreamReader reader = new StreamReader(TwitterResponse.GetResponseStream()))
                    {
                        while (true)
                        {
                            var line = reader.ReadLine();
                            if (String.IsNullOrEmpty(line)) continue;

                            dynamic obj = JsonConvert.DeserializeObject(line);

                            if (obj.user != null)
                                Console.WriteLine(obj.user.screen_name + ": " + obj.text);

                        }
                    }

The signature is working fine for other APIs. Can you please tell me if I am missing something.


#2

I get the same error.


#3

Hello Arshad and Hampus,

Please make sure the time on your servers is correct. The system clock is used by the OAuth implementation and needs to be in sync with the Twitter servers. You can check the current time in the “Date” HTTP header returned with every request.

Read more about Troubleshooting OAuth 1.0A at https://dev.twitter.com/discussions/204 and please let us know if that fixes your issues.


#4

Thank you! With only 6 minutes difference I was suffering this trouble.


#5

The clock is synchronized. Do I use GET or POST? I am using GET. If that’s correct, then what’s the issue?


#6

http://takipci.info/


#7

Omer,

I don’t understand the language.


#8

Hello Arshad, this endpoint requires a POST. Please see [node:10389].