Sha256: a4adcc13f8941dfbe34db8266910fb0d7010ce7cb30ae2ba235f450840821d51

Contents?: true

Size: 980 Bytes

Versions: 6

Compression:

Stored size: 980 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 = new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
      token.params = hash
      token
    end

    def initialize(consumer, token = "", secret = "")
      super(token, secret)
      @consumer = consumer
      @params   = {}
    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

6 entries across 6 versions & 1 rubygems

Version Path
oauth-0.5.14 lib/oauth/tokens/consumer_token.rb
oauth-0.5.13 lib/oauth/tokens/consumer_token.rb
oauth-0.5.12 lib/oauth/tokens/consumer_token.rb
oauth-0.5.11 lib/oauth/tokens/consumer_token.rb
oauth-0.5.10 lib/oauth/tokens/consumer_token.rb
oauth-0.5.9 lib/oauth/tokens/consumer_token.rb