Class: AmadeusDiscover::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/amadeus_discover/authenticator.rb,
lib/amadeus_discover/authenticator/token.rb,
lib/amadeus_discover/authenticator/response.rb,
lib/amadeus_discover/authenticator/credentials.rb

Overview

Authenticator to be used with Faraday’s Authentication Middleware

Authentication Middleware and this are automatically injected into your connection stack so you don’t need to configure them.

Constant Summary collapse

ENDPOINT =
'/auth/realms/amadeus-discover/protocol/openid-connect/token'

Instance Method Summary collapse

Constructor Details

#initialize(connection, credentials = {}) ⇒ Authenticator

Returns a new instance of Authenticator.



15
16
17
18
# File 'lib/amadeus_discover/authenticator.rb', line 15

def initialize(connection, credentials = {})
  @connection = reconfigure(connection)
  @credentials = Credentials.new(credentials)
end

Instance Method Details

#bearer_tokenObject



20
21
22
23
# File 'lib/amadeus_discover/authenticator.rb', line 20

def bearer_token
  @token = nil unless token.valid?
  token.value
end