`on_headers_complete': Twitter::Error::Unauthorized

ruby

#1

Hey guys,
I’m using twitter gem
The REST API is working well but when I try to use the Streaming one I have trouble getting

`on_headers_complete’: Twitter::Error::Unauthorized

All my keys are working with the REST API but not with the streaming one.
Thanks for your help


#2

Can you share any code example? That’s weird.


#3

Sure,
so for the REST API, I’m initializing like this

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "....................."
  config.consumer_secret     = ".............................."
  config.access_token        = "........................................................"
  config.access_token_secret = "..........................................."
end

# calling for example 
client.update("blablablabla")

and it works well.

On the Streaming side.
I’m initializing the same way :

client = Twitter::Streaming::Client.new do |config|
  config.consumer_key        = "....................."
  config.consumer_secret     = ".............................."
  config.access_token        = "........................................................"
  config.access_token_secret = "..........................................."
end

#calling for example
 client.sample()
#or any other methods

And i get =>

/usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:21:in `on_headers_complete': Twitter::Error::Unauthorized
    from /usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:16:in `<<'
    from /usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/response.rb:16:in `<<'
    from /usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/connection.rb:22:in `stream'
    from /usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/client.rb:119:in `request'
    from /usr/local/lib/ruby/gems/2.3.0/gems/twitter-5.16.0/lib/twitter/streaming/client.rb:58:in `sample'
    from noko.rb:17:in `<main>'

Thanks for the help


#4

Hey Andy do you need some more informations?
Thanks


#5

No, but I haven’t had a chance to look at this as I’m travelling. Perhaps someone else can see what is going on here. A common issue is that times can drift on the client and cause OAuth signatures to fail, but that doesn’t make sense in your case if the REST code works, and just the Streaming example doesn’t.