title: Getting 400 error when trying to get auth token - twitter omniauth
body: <p>I've got a rails app in which I am trying to implement twitter omniauth so many users can post/get to/from many twitter accounts from within the app. I have followed the <a href="http://railscasts.com/episodes/241-simple-omniauth-revised" rel="nofollow">railscasts</a> (until about 3 minutes in) on the topic exactly yet am getting a 400 http response. </p>
  
  <p>In my gemfile:</p>
  
  <pre><code>gem 'omniauth'
  gem 'omniauth-twitter'
  </code></pre>
  
  <p>In <code>/config/initializers/omniauth.rb</code></p>
  
  <pre><code>Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'],
  end
  </code></pre>
  
  <p>In my view I naturally have  <code>&lt;%= link_to "Connect", "/auth/twitter" %&gt;</code> and in my <code>routes.rb</code> I have (this is the only difference to the railscast as I am not using it to signup/login users but rather to post to twitter): </p>
  
  <pre><code>get 'auth/:provider/callback', to: 'twitter_accounts#create'
  get 'auth/failure', to: redirect('/')
  </code></pre>
  
  <p>Clicking the link in the view results in the following error:</p>
  
  <pre><code>OAuth::Unauthorized
  400 Bad Request
  </code></pre>
  
  <p>As far as I can see my api key &amp; secret are correct so it seems that it is not setting the http header correctly. The request and response params are empty on the rails error page. Any help would be greatly appreciated.</p>