Class: Auth::ClientCredentials::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- Auth::ClientCredentials::Configuration
- 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
-
.base_request_headers ⇒ Hash
The basic headers required for any token service API call.
Instance Method Summary collapse
-
#connection ⇒ Faraday::Connection
Creates a Faraday connection with parsing json and adding breakers functionality.
-
#get_access_token(url, body) ⇒ Farday::Response
The response containing data needed to make further API calls.
Methods inherited from Common::Client::Configuration::Base
#base_path, #breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception, #service_name
Class Method Details
.base_request_headers ⇒ Hash
Returns 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
#connection ⇒ Faraday::Connection
Creates a Faraday connection with parsing json and adding breakers functionality.
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: ) 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.
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 |