Sha256: 65937d8da68e77224609f35537edf86fafef69bc48d7e55474f83663bc2e414a

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

# Lightweight example of an oauth2 provider used by the ruby client.
class TestOAuth2Provider < SparkApi::Authentication::BaseOAuth2Provider
  
  def initialize
    @authorization_uri = "https://test.fbsdata.com/r/oauth2"
    @access_uri = "https://api.test.fbsdata.com/v1/oauth2/grant"
    @redirect_uri = "https://exampleapp.fbsdata.com/oauth-callback"
    @client_id="example-id"
    @client_secret="example-password"    
    @session_cache = {}
  end
  
  def redirect(url)
    # User redirected to url, signs in, and gets code sent to callback
    self.code="my_code"
  end
  
  def load_session()
    @session_cache["test_user_session"]
  end
  
  def save_session(session)
    @session_cache["test_user_session"] = session
    nil
  end
  
  def session_timeout; 7200; end
  
end


class TestCLIOAuth2Provider < SparkApi::Authentication::BaseOAuth2Provider
  def initialize
    @authorization_uri = "https://test.fbsdata.com/r/oauth2"
    @access_uri = "https://api.test.fbsdata.com/v1/oauth2/grant"
    @client_id="example-id"
    @client_secret="example-secret"
    @username="example-user"
    @password="example-password"
    @session_cache = {}
  end
  
  def grant_type
    :password
  end
  
  def redirect(url)
    raise "Unsupported in oauth grant_type=password mode"
  end
  
  def load_session()
    @session_cache["test_user_session"]
  end
  def save_session(session)
    @session_cache["test_user_session"] = session
    nil
  end
  def session_timeout; 60; end
end


class InvalidAuth2Provider < SparkApi::Authentication::BaseOAuth2Provider
  
  def grant_type
    :not_a_real_type
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spark_api-1.1.2 spec/oauth2_helper.rb
spark_api-1.1.1 spec/oauth2_helper.rb
spark_api-1.1.0 spec/oauth2_helper.rb
spark_api-1.0.4 spec/oauth2_helper.rb
spark_api-1.0.2 spec/oauth2_helper.rb
spark_api-1.0.1 spec/oauth2_helper.rb
spark_api-1.0.0 spec/oauth2_helper.rb