Class: Corelogic::Authenticator
- Inherits:
-
Object
- Object
- Corelogic::Authenticator
- Extended by:
- Dry::Initializer
- Defined in:
- lib/corelogic/authenticator.rb
Constant Summary collapse
- OAUTH_URL =
'https://api-prod.corelogic.com/oauth/token'.freeze
Instance Method Summary collapse
Instance Method Details
#call(connection, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/corelogic/authenticator.rb', line 14 def call(connection, = {}) = .dup [:grant_type] ||= 'client_credentials' force = .delete(:force) || false return connection if !force && connection.authenticated? response = HTTP.basic_auth(credentials).post(OAUTH_URL, params: ) token = Corelogic::ResponseParser.perform(response)[:access_token] connection.bearer_token = token connection end |