Sha256: 8107fb883653e8aa02823ead4766f77b6894a4f72b024eff71d61a8742ca261e
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
class ExvoAuth::Autonomous::Provider 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[:consumer_id].nil? || options[:access_token].nil? raise(ArgumentError, "Please configure site, client_id, client_secret, consumer_id and access_token") end @options = options end def scopes @@cache.fetch(options) do scopes! end end def scopes! response = HTTParty.get("/apps/provider/authorizations/#{options[:consumer_id]}.json", :base_uri => options[:site], :basic_auth => { :username => options[:client_id], :password => options[:client_secret] }, :query => { :access_token => options[:access_token] } ) @@cache.write(options, response["scope"].to_s.split) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
exvo-auth-0.6.1 | lib/exvo_auth/autonomous/provider.rb |
exvo-auth-0.6.0 | lib/exvo_auth/autonomous/provider.rb |