Sha256: cce71cc8cfc45294c2c4f649d12f1cb8900a84abbcdab802434aebc328ca2945

Contents?: true

Size: 705 Bytes

Versions: 12

Compression:

Stored size: 705 Bytes

Contents

class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
  include ExvoAuth::Autonomous::Http
  
  def initialize(params = {})
    super
    validate_params!(:provider_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[:provider_id])}.json")
    
    if response["authorization"]
      @@cache.write(params, response["authorization"])
    else
      raise "Unauthorized"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
exvo-auth-0.9.7 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.6 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.5 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.4 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.3 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.2 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.9.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.8.2 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.8.0 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.7.16 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.7.15 lib/exvo_auth/autonomous/consumer.rb
exvo-auth-0.7.14 lib/exvo_auth/autonomous/consumer.rb