Class: Neoway::Auth::AuthenticatedConnection

Inherits:
Connection
  • Object
show all
Defined in:
lib/neoway/auth/authenticated_connection.rb

Constant Summary collapse

"NEOWAY_AUTHENTICATION_COOKIE_CACHE_KEY"

Instance Method Summary collapse

Constructor Details

#initialize(authentication: Neoway::Auth::Authentication.new, cache: default_cache) ⇒ AuthenticatedConnection

Returns a new instance of AuthenticatedConnection.



8
9
10
11
12
13
14
# File 'lib/neoway/auth/authenticated_connection.rb', line 8

def initialize(authentication: Neoway::Auth::Authentication.new, cache: default_cache)
  super(request_class: request_class, base_url: base_url)

  @authentication = authentication
  @cache = cache
  @expiration_time = Neoway::Auth::TOKEN_EXPIRATION.seconds
end

Instance Method Details

#default_headersObject



16
17
18
# File 'lib/neoway/auth/authenticated_connection.rb', line 16

def default_headers
  super.merge(Authorization: (@cache ? cached_token : auth_token))
end