Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created November 20, 2011 23:36
Show Gist options
  • Save johana-star/1381160 to your computer and use it in GitHub Desktop.
Save johana-star/1381160 to your computer and use it in GitHub Desktop.
Authenticate a twitter session as per the example at http://twitter.rubyforge.org/, but obfuscate the secrets into a YAML config file.
require 'twitter'
require 'yaml'
def authenticate
Twitter.configure do |c|
config = YAML.load(File.read("config.yml"))[:twitter]
c.consumer_key = config[:consumer_key]
c.consumer_secret = config[:consumer_secret]
c.oauth_token = config[:oauth_token]
c.oauth_token_secret = config[:oauth_token_secret]
end
@client = Twitter::Client.new
end
:twitter:
:consumer_key: CONSUMER_KEY
:consumer_secret: CONSUMER_SECRET
:oauth_token: OAUTH_TOKEN
:oauth_token_secret: OAUTH_TOKEN_SECRET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment