Sha256: 5efb6d8d65548f675c426b618795dbeb61f65872697a326496576e673217bc4d

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

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

      puts "1) open: #{request_token.authorize_url}"
      browse(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

4 entries across 4 versions & 1 rubygems

Version Path
earthquake-0.7.5 lib/earthquake/get_access_token.rb
earthquake-0.7.4 lib/earthquake/get_access_token.rb
earthquake-0.7.2 lib/earthquake/get_access_token.rb
earthquake-0.7.1 lib/earthquake/get_access_token.rb