Sha256: 879de624f28000292aaac76cc3eb4075dca6dcd360f98913c68bdb840b4ae75c

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module Earthquake
  module GetAccessToken
    def get_access_token
      consumer = OAuth::Consumer.new(
        self.config[:consumer_key],
        self.config[:consumer_secret],
        :site => 'http://api.twitter.com'
      )
      request_token = consumer.get_request_token

      puts "1) open: #{request_token.authorize_url}"
      Launchy::Browser.run(request_token.authorize_url) rescue nil

      print "2) Enter the PIN: "
      pin = STDIN.gets.strip

      access_token = request_token.get_access_token(:oauth_verifier => pin)
      config[:token] = access_token.token
      config[:secret] = access_token.secret

      puts "Saving 'token' and 'secret' to '#{config[:file]}'"
      File.open(config[:file], 'a') do |f|
        f << "Earthquake.config[:token] = '#{config[:token]}'"
        f << "\n"
        f << "Earthquake.config[:secret] = '#{config[:secret]}'"
      end
    end
  end

  extend GetAccessToken
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
earthquake-0.5.9 lib/earthquake/get_access_token.rb