Sha256: 2ba370f16550522cf3c931e315d1ccbadbf991dde933e3fbd46350fdb3266dfc
Contents?: true
Size: 1000 Bytes
Versions: 2
Compression:
Stored size: 1000 Bytes
Contents
class ExvoAuth::Autonomous::Consumer attr_reader :options @@cache = ExvoAuth::Autonomous::Cache.new def initialize(options = {}) options[:site] ||= ExvoAuth::Config.host options[:client_id] ||= ExvoAuth::Config.client_id options[:client_secret] ||= ExvoAuth::Config.client_secret if options[:site].nil? || options[:client_id].nil? || options[:client_secret].nil? || options[:provider_id].nil? raise(ArgumentError, "Please configure site, client_id, client_secret and provider_id") end @options = options end def access_token @@cache.fetch(options) do access_token! end end def access_token! response = HTTParty.get("/apps/consumer/authorizations/#{options[:provider_id]}.json", :base_uri => options[:site], :basic_auth => { :username => options[:client_id], :password => options[:client_secret] } ) @@cache.write(options, response["access_token"]) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
exvo-auth-0.6.1 | lib/exvo_auth/autonomous/consumer.rb |
exvo-auth-0.6.0 | lib/exvo_auth/autonomous/consumer.rb |