I’m ussing the OAuth Ruby Gem as follows:
consumer = OAuth::Consumer.new(, , {:site => “http://api.twitter.com”})
token = OAuth::AccessToken.new(consumer, , )
request_string = "http://api.twitter.com/1/statuses/home_timeline.json?count=1"
response = token.get(request_string)
response = token.get(request_string)
response = token.get(request_string)
response = token.get(request_string)
response = token.get(request_string)
And I get the following response:
irb(main):120:0> response = token.get(request_string)
=> #<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
irb(main):121:0> response = token.get(request_string)
=> #<Net::HTTPOK 200 OK readbody=true>
irb(main):122:0> response = token.get(request_string)
=> #<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
irb(main):123:0> response = token.get(request_string)
=> #<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
irb(main):124:0> response = token.get(request_string)
=> #<Net::HTTPOK 200 OK readbody=true>
I also tried
consumer = OAuth::Consumer.new(, , {:site => “http://api.twitter.com”, :scheme => :header})
While using the same application credentials and the same user-data, the api call sometimes succeed and many other times fails with 401 error.
What’s wrong with the code I’m using?