Sha256: dfcacbebb48ae041cdf62d19fa7fef9741a9ada35f03cab70f8a3a3e28a254c1

Contents?: true

Size: 779 Bytes

Versions: 16

Compression:

Stored size: 779 Bytes

Contents

class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
  include ExvoAuth::Autonomous::Http
  
  def initialize(params = {})
    super
    validate_params!(:app_id)
  end
  
  def base_uri
    authorization["url"]
  end
  
  def username
    ExvoAuth::Config.client_id
  end
  
  def password
    authorization["access_token"]
  end
  
  def authorization
    @@cache.fetch(params) do
      authorization!
    end
  end
  
  def authorization!
    response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:app_id])}.json")
    
    if response["authorization"]
      @@cache.write(params, response["authorization"])
    else
      raise "Authorization not found. You need an auhorization to contact provider app (#{ params[:app_id] })"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
exvo-auth-0.14.1 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.14.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.13.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.12.2 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.12.1 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.12.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.11.2 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.11.1 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.11.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.10.4 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.10.3 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.10.2 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.10.1 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.10.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.10 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.9 lib/exvo_auth/autonomous/consumer.rb