Skip to content

Instantly share code, notes, and snippets.

@terenceponce
Created August 13, 2012 11:31
Show Gist options
  • Save terenceponce/3339833 to your computer and use it in GitHub Desktop.
Save terenceponce/3339833 to your computer and use it in GitHub Desktop.
Twitter gem error: unauthorized

I can't follow/unfollow users with the Twitter gem because Twitter could not authenticate me.

I've written the Twitter app credentials in config/config.yml and I've loaded it in config/initializers/app_config.rb:

APP_CONFIG = YAML.load_file(Rails.root.join('config', 'config.yml'))

After I do Twitter.follow(username), I get a Twitter::Error::Unauthorized exception

Did I miss anything?

# config/initializers/twitter.rb
Twitter.configure do |config|
config.consumer_key = APP_CONFIG['twitter_consumer_key']
config.consumer_secret = APP_CONFIG['twitter_consumer_secret']
config.oauth_token = APP_CONFIG['twitter_oauth_token']
config.oauth_token_secret = APP_CONFIG['twitter_oauth_secret']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment