Sha256: 1437524d7626a3dd48b13818394b14235b4b1e54034fae97c94c51d3399937d9

Contents?: true

Size: 1.25 KB

Versions: 24

Compression:

Stored size: 1.25 KB

Contents

module Twitter
  class OAuth
    extend Forwardable
    def_delegators :access_token, :get, :post
    
    attr_reader :ctoken, :csecret, :consumer_options
    
    # Options
    #   :sign_in => true to just sign in with twitter instead of doing oauth authorization
    #               (http://apiwiki.twitter.com/Sign-in-with-Twitter)
    def initialize(ctoken, csecret, options={})
      @ctoken, @csecret, @consumer_options = ctoken, csecret, {}
      
      if options[:sign_in]
        @consumer_options[:authorize_path] =  '/oauth/authenticate'
      end
    end
    
    def consumer
      @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'}.merge(consumer_options))
    end
    
    def request_token
      @request_token ||= consumer.get_request_token
    end
    
    def authorize_from_request(rtoken, rsecret)
      request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
      access_token = request_token.get_access_token
      @atoken, @asecret = access_token.token, access_token.secret
    end
    
    def access_token
      @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret)
    end
    
    def authorize_from_access(atoken, asecret)
      @atoken, @asecret = atoken, asecret
    end
  end
end

Version data entries

24 entries across 24 versions & 14 rubygems

Version Path
arthurgeek-twitter-0.6.15 lib/twitter/oauth.rb
ddollar-twitter-0.6.15 lib/twitter/oauth.rb
ddollar-twitter-0.6.16 lib/twitter/oauth.rb
ddollar-twitter-0.6.17 lib/twitter/oauth.rb
deadprogrammer-twitter-0.6.11 lib/twitter/oauth.rb
deadprogrammer-twitter-0.6.12 lib/twitter/oauth.rb
deedubs-twitter-0.7.0 lib/twitter/oauth.rb
deedubs-twitter-0.8.0 lib/twitter/oauth.rb
egze-twitter-0.6.13 lib/twitter/oauth.rb
erwaller-twitter-0.6.13.1 lib/twitter/oauth.rb
erwaller-twitter-0.6.13 lib/twitter/oauth.rb
jnunemaker-twitter-0.6.11 lib/twitter/oauth.rb
jnunemaker-twitter-0.6.12 lib/twitter/oauth.rb
jnunemaker-twitter-0.6.13 lib/twitter/oauth.rb
jnunemaker-twitter-0.6.14 lib/twitter/oauth.rb
michaeltaras-twitter-0.6.13 lib/twitter/oauth.rb
ministrycentered-twitter-0.6.12 lib/twitter/oauth.rb
nobert-twitter-0.6.12 lib/twitter/oauth.rb
nobert-twitter-0.6.13 lib/twitter/oauth.rb
paulsingh-twitter-0.6.13 lib/twitter/oauth.rb