Sha256: abe6fa4c221b3bb92b79cd3977687f69210b029ab8898f592c3d200ca8bf7476

Contents?: true

Size: 696 Bytes

Versions: 1

Compression:

Stored size: 696 Bytes

Contents

class ExvoAuth::Autonomous::Provider < ExvoAuth::Autonomous::Base
  def initialize(options = {})
    super
    validate_options!(:consumer_id, :access_token)
  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] }
    )

    if scope = response["scope"] # only cache positive responses
      @@cache.write(options, scope.split)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exvo-auth-0.6.2 lib/exvo_auth/autonomous/provider.rb