Twitter gem not authenticating correctly
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Here's the issue described on the gem's mailing list:

https://groups.google.com/forum/?fromgroups=#!topic/ruby-twitter-gem/1idy65HDWAw

Like the google group suggests, the first thing I suggest doing is testing the environment variables
skram over 9 years ago
The ENV variables are working fine with the rest of omniauth
saiko-chriskun over 9 years ago
Also- I can auth perfectly fine if I interact with twitter's http api directly and encode all the headers and such myself. The keys and variables all work fine. I would just rather use a community supported gem.
saiko-chriskun over 9 years ago
awarded to DanKnox

Crowdsource coding tasks.

1 Solution

Winning solution

You have an error in your initializer code.

Twitter.configure do |config|
  config.consumer_key = ENV['TWITTER_KEY'], # <-- Should not have a comma
  config.consumer_secret = ENV['TWITTER_SECRET']
end

It needs to be this:

Twitter.configure do |config|
  config.consumer_key = ENV['TWITTER_KEY'] # <-- No Comma
  config.consumer_secret = ENV['TWITTER_SECRET']
end

I haven't yet taken the time to look at the twitter gem but it must be silently swallowing the exception when the initializer is executing.

I tested the changes and it works great. I have also submitted a pull request to your repository with this fix in place.

Good catch, @DanKnox!
skram over 9 years ago