I'm developing a web app that will let users tweet posts and links, but I can't seem to get Twitter and Omniauth to play nicely together. I'm currently running on Rails 3.0.6 and Ruby 1.8.7, with the Twitter gem 1.4.1 and Omniauth gem 0.2.5
I can authenticate the users fine, but when it comes to sending a tweet, I'm just given the error:
POST https://api.twitter.com/1/statuses/update.json: 401: Incorrect signature
I followed this tutorial, and have placed my consumer key and consumer secret in a Twitter configure block in my Omniauth initializer, but not the oauth token or oauth secret because these will surely be used on a per-user basis.
omniauth.rb
Twitter.configure do |config|
config.consumer_key = "XXXXXXXXXXXXXXXXXXXXXX"
config.consumer_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
end
user.rb
def twitter
unless @twitter_user
provider = self.authentications.find_by_provider('twitter')
@twitter_user = Twitter::Client.new(:oauth_token => provider.token, :oauth_token_secret => provider.secret) rescue nil
end
@twitter_user
end
I then form the request using:
current_user.twitter.update("Hello World!")
And that's what then gives me the 401 error.
Any ideas? Thanks!