Sha256: 847027c49060d21f2cf80021befa28ec97e578e646d218cd4fc8729884365e2e

Contents?: true

Size: 960 Bytes

Versions: 16

Compression:

Stored size: 960 Bytes

Contents

module OAuth
  # Superclass for tokens used by OAuth Clients
  class ConsumerToken < Token
    attr_accessor :consumer, :params
    attr_reader   :response

    def self.from_hash(consumer, hash)
      token = self.new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
      token.params = hash
      token
    end

    def initialize(consumer, token="", secret="")
      super(token, secret)
      @consumer = consumer
    end

    # Make a signed request using given http_method to the path
    #
    #   @token.request(:get,  '/people')
    #   @token.request(:post, '/people', @person.to_xml, { 'Content-Type' => 'application/xml' })
    #
    def request(http_method, path, *arguments)
      @response = consumer.request(http_method, path, self, {}, *arguments)
    end

    # Sign a request generated elsewhere using Net:HTTP::Post.new or friends
    def sign!(request, options = {})
      consumer.sign!(request, self, options)
    end
  end
end

Version data entries

16 entries across 16 versions & 6 rubygems

Version Path
metavida-oauth-0.3.2.1 lib/oauth/tokens/consumer_token.rb
metavida-oauth-0.3.2 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.1.6 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.1.7 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.1.8 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.2.1 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.2.2 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.2 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.3 lib/oauth/tokens/consumer_token.rb
mojodna-oauth-0.3.4 lib/oauth/tokens/consumer_token.rb
vincentchu-oauth-0.3.2.111 lib/oauth/tokens/consumer_token.rb
zmalltalker-oauth-0.3.1.7 lib/oauth/tokens/consumer_token.rb
af-oauth-0.3.4.1 lib/oauth/tokens/consumer_token.rb
oauth-0.3.2 lib/oauth/tokens/consumer_token.rb
oauth-0.3.4 lib/oauth/tokens/consumer_token.rb
oauth-0.3.3 lib/oauth/tokens/consumer_token.rb