Class: Auth::ClientCredentials::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/lighthouse/auth/client_credentials/configuration.rb

Overview

HTTP client configuration for the Service, sets the base path, the base request headers, and a service name for breakers and metrics.

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common::Client::Configuration::Base

#base_path, #breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #request_options, #service_exception, #service_name

Class Method Details

.base_request_headersHash

Returns The basic headers required for any token service API call.

Returns:

  • (Hash)

    The basic headers required for any token service API call.



17
18
19
# File 'lib/lighthouse/auth/client_credentials/configuration.rb', line 17

def self.base_request_headers
  super.merge({ 'Content-Type': 'application/x-www-form-urlencoded' })
end

Instance Method Details

#connectionFaraday::Connection

Creates a Faraday connection with parsing json and adding breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



34
35
36
37
38
39
40
41
42
# File 'lib/lighthouse/auth/client_credentials/configuration.rb', line 34

def connection
  @conn ||= Faraday.new(headers: base_request_headers, request: request_options) do |faraday|
    faraday.use      :breakers
    faraday.use      Faraday::Response::RaiseError

    faraday.response :json
    faraday.adapter Faraday.default_adapter
  end
end

#get_access_token(url, body) ⇒ Farday::Response

Returns The response containing data needed to make further API calls.

Returns:

  • (Farday::Response)

    The response containing data needed to make further API calls.



25
26
27
# File 'lib/lighthouse/auth/client_credentials/configuration.rb', line 25

def get_access_token(url, body)
  connection.post(url, URI.encode_www_form(body))
end