Class: MultiAuthSample::ApiHeader

Inherits:
CoreLibrary::HeaderAuth
  • Object
show all
Defined in:
lib/multi_auth_sample/http/auth/api_header.rb

Overview

Utility class for custom header authorization.

Instance Method Summary collapse

Constructor Details

#initialize(api_header_credentials) ⇒ ApiHeader

Initialization constructor.



16
17
18
19
20
21
22
23
24
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 16

def initialize(api_header_credentials)
  auth_params = {}
  auth_params['token'] = api_header_credentials.token unless
    api_header_credentials.nil? || api_header_credentials.token.nil?
  auth_params['api-key'] = api_header_credentials.api_key unless
    api_header_credentials.nil? || api_header_credentials.api_key.nil?

  super auth_params
end

Instance Method Details

#error_messageObject

Display error message on occurrence of authentication failure.



11
12
13
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 11

def error_message
  'ApiHeader: token or api_key is undefined.'
end