Module: FlexmlsApi::Authentication

Included in:
Client
Defined in:
lib/flexmls_api/authentication.rb,
lib/flexmls_api/authentication/oauth2.rb,
lib/flexmls_api/authentication/api_auth.rb,
lib/flexmls_api/authentication/base_auth.rb,
lib/flexmls_api/authentication/oauth2_impl/middleware.rb,
lib/flexmls_api/authentication/oauth2_impl/grant_type_base.rb,
lib/flexmls_api/authentication/oauth2_impl/grant_type_code.rb,
lib/flexmls_api/authentication/oauth2_impl/password_provider.rb,
lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb,
lib/flexmls_api/authentication/oauth2_impl/grant_type_password.rb

Overview

Authentication

Mixin module for handling client authentication and reauthentication to the flexmls api. Makes use of the configured authentication mode (API Auth by default).

Defined Under Namespace

Modules: OAuth2Impl Classes: ApiAuth, BaseAuth, BaseOAuth2Provider, OAuth2, OAuthSession, Session

Instance Method Summary collapse

Instance Method Details

#authenticateObject

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


25
26
27
28
29
30
31
32
# File 'lib/flexmls_api/authentication.rb', line 25

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

#authenticated?Boolean

Test to see if there is an active session

Returns:

  • (Boolean)


35
36
37
# File 'lib/flexmls_api/authentication.rb', line 35

def authenticated?
  @authenticator.authenticated?
end

#logoutObject

Delete the current session



40
41
42
43
# File 'lib/flexmls_api/authentication.rb', line 40

def logout
  FlexmlsApi.logger.info("Logging out.")
  @authenticator.logout
end

#sessionObject

Fetch the active session object



46
47
48
# File 'lib/flexmls_api/authentication.rb', line 46

def session
  @authenticator.session
end

#session=(active_session) ⇒ Object

Save the active session object



50
51
52
# File 'lib/flexmls_api/authentication.rb', line 50

def session=(active_session)
  @authenticator.session=active_session
end