Reputation: 19723
I am using the Twitter gem at (https://github.com/jnunemaker/twitter). Keep getting Twitter::Error::Unauthorized, only with some users. For other users, the request is fulfilled without any problems.
user = User.first
client = Twitter::Client.new(:oauth_token => user.authentications.where(:provider => 'twitter').first.token, :oauth_token_secret => user.authentications.where(:provider => 'twitter').first.secret)
client.follower_ids
The exact error: Twitter::Error::Unauthorized: This method requires authentication.
This happens on a case to case basis. The problem affects a number of users on our system. The first thing you might think, is that their oauth_token
and oauth_token_secret
might be invalid. I am storing these tokens the same way I am storing the tokens for every user. So there is no reason to suspect that the tokens may be invalid.
Anyone know why?
Upvotes: 4
Views: 2464
Reputation: 504
The Could not authenticate with OAuth
error means the oauth_token
and oauth_secret
are no longer valid.
Earlier today we had some similar reports saying the values copied directly from the Your access token section of this site were not working.
Upvotes: 1
Reputation: 9791
I had the same problem and came with a silly solution. The twitter API changed and you need your oauth_token and your oauth_token_secret(even though you post with somebody else their token). You have to generate them in the twitter developer page. Kind of double.... But it worked for me.
Twitter.configure do |config|
config.consumer_key = 'key'
config.consumer_secret = 'secret'
config.oauth_token = 'oauth_token'
config.oauth_token_secret = 'oauth_token_secret'
end
Hope it helps!
Upvotes: 0