Class: FolioClient::Authenticator
- Inherits:
-
Object
- Object
- FolioClient::Authenticator
- Defined in:
- lib/folio_client/authenticator.rb
Overview
Fetch a token from the Folio API using login_params
Class Method Summary collapse
Instance Method Summary collapse
-
#token ⇒ Object
Request an access_token.
Class Method Details
.token ⇒ Object
6 7 8 |
# File 'lib/folio_client/authenticator.rb', line 6 def self.token new.token end |
Instance Method Details
#token ⇒ Object
Request an access_token
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/folio_client/authenticator.rb', line 11 def token # rubocop:disable Metrics/AbcSize response = FolioClient.connection.post(login_endpoint, FolioClient.config.login_params.to_json) UnexpectedResponse.call(response) unless response.success? # remove legacy_auth once new tokens enabled on Poppy if FolioClient.config.legacy_auth JSON.parse(response.body)['okapiToken'] else = FolioClient...find { || .name == 'folioAccessToken' } raise StandardError, "Problem with folioAccessToken cookie: #{response.headers}, #{response.body}" unless .value end end |