title: Tweeting using Twitter gem and Omniauth
body: <p>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</p>
  
  <p>I can authenticate the users fine, but when it comes to sending a tweet, I'm just given the error:</p>
  
  <pre><code> POST https://api.twitter.com/1/statuses/update.json: 401: Incorrect signature
  </code></pre>
  
  <p>I followed <a href="http://blog.assimov.net/post/2358661274/twitter-integration-with-omniauth-and-devise-on-rails-3" rel="nofollow">this tutorial</a>, 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.</p>
  
  <p><em>omniauth.rb</em></p>
  
  <pre><code> Twitter.configure do |config|
     config.consumer_key = "XXXXXXXXXXXXXXXXXXXXXX"
     config.consumer_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
   end
  </code></pre>
  
  <p><em>user.rb</em></p>
  
  <pre><code>  def twitter
       unless @twitter_user
         provider = self.authentications.find_by_provider('twitter')
         @twitter_user = Twitter::Client.new(:oauth_token =&gt; provider.token, :oauth_token_secret =&gt; provider.secret) rescue nil
       end
       @twitter_user
    end
  </code></pre>
  
  <p>I then form the request using:</p>
  
  <pre><code> current_user.twitter.update("Hello World!")
  </code></pre>
  
  <p>And that's what then gives me the 401 error.</p>
  
  <p>Any ideas? Thanks!</p>