Sha256: 44f606e441bcbf336e16d8a61a4798c7de9e3e98cb7953111d63399e04f2c050

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require File.dirname(__FILE__) + "/../cli/setup"

class CLIOAuth2Provider < FlexmlsApi::Authentication::BaseOAuth2Provider
  def initialize(credentials)
    @authorization_uri = credentials[:authorization_uri]
    @access_uri        = credentials[:access_uri]
    @redirect_uri      = credentials[:redirect_uri]
    @client_id         = credentials[:client_id]
    @client_secret     = credentials[:client_secret]
    @username          = credentials[:username]
    @password          = credentials[:password]
    @session           = nil
  end

  def grant_type
    :password
  end
  
  def load_session()
    @session
  end

  def save_session(session)
    @session = session
  end

  def destroy_session
    @session = nil
  end
end

FlexmlsApi.configure do |config|
  config.oauth2_provider = CLIOAuth2Provider.new(
                            :authorization_uri=> ENV["AUTH_URI"],
                            :access_uri  => ENV["ACCESS_URI"],
                            :username=> ENV["USERNAME"],
                            :password=> ENV["PASSWORD"],
                            :client_id=> ENV["CLIENT_ID"],
                            :client_secret=> ENV["CLIENT_SECRET"]
                          ) 
  config.authentication_mode = FlexmlsApi::Authentication::OAuth2
  config.endpoint = ENV["API_ENDPOINT"] if ENV["API_ENDPOINT"]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexmls_api-0.6.5 lib/flexmls_api/cli/oauth2.rb
flexmls_api-0.6.4 lib/flexmls_api/cli/oauth2.rb