Sha256: 0bcbe12336d42238b7e3245ece2c31544843f38a5547d3ff0f1fbc62df32d158
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
require 'openssl' require 'faraday' require 'faraday_middleware' require 'yajl' require 'date' require 'flexmls_api/authentication/base_auth' require 'flexmls_api/authentication/api_auth' require 'flexmls_api/authentication/oauth2' module FlexmlsApi # =Authentication # Mixin module for handling client authentication and reauthentication to the flexmls api. Makes # use of the configured authentication mode (API Auth by default). module Authentication # Main authentication step. Run before any api request unless the user session exists and is # still valid. # # *returns* # The user session object when authentication succeeds # *raises* # FlexmlsApi::ClientError when authentication fails def authenticate start_time = Time.now request_time = Time.now - start_time new_session = @authenticator.authenticate FlexmlsApi.logger.info("[#{(request_time * 1000).to_i}ms]") FlexmlsApi.logger.debug("Session: #{new_session.inspect}") new_session end # Test to see if there is an active session def authenticated? @authenticator.authenticated? end # Delete the current session def logout FlexmlsApi.logger.info("Logging out.") @authenticator.logout end # Fetch the active session object def session @authenticator.session end # Save the active session object def session=(active_session) @authenticator.session=active_session end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flexmls_api-0.7.3 | lib/flexmls_api/authentication.rb |
flexmls_api-0.7.5 | lib/flexmls_api/authentication.rb |