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
Constant Summary collapse
- LOGIN_ENDPOINT =
'/authn/login-with-expiry'
Class Method Summary collapse
-
.refresh_token! ⇒ String
Request an access_token.
Class Method Details
.refresh_token! ⇒ String
Request an access_token
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/folio_client/authenticator.rb', line 12 def self.refresh_token! response = FolioClient.connection.post(LOGIN_ENDPOINT, FolioClient.config.login_params.to_json) UnexpectedResponse.call(response) unless response.success? = FolioClient...find { || .name == 'folioAccessToken' } # NOTE: The client typically delegates raising exceptions (based on HTTP # responses) to the UnexpectedResponse class, but this call in # Authenticator is a one-off, unlike any other in the app, so we # allow it to customize its exception handling. raise UnauthorizedError, "Problem with folioAccessToken cookie: #{response.headers}, #{response.body}" unless .value end |