Class: SdrClient::RedesignedClient::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/redesigned_client/authenticator.rb

Overview

Fetch a token from the SDR API using user credentials

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.tokenObject



7
8
9
# File 'lib/sdr_client/redesigned_client/authenticator.rb', line 7

def self.token
  new.token
end

Instance Method Details

#tokenObject

Request an access_token



12
13
14
15
16
17
18
# File 'lib/sdr_client/redesigned_client/authenticator.rb', line 12

def token
  response = connection.post(path, request_body, content_type: 'application/json')

  UnexpectedResponse.call(response) unless response.success?

  JSON.parse(response.body)['token']
end