Module: Huntress::Authentication
- Included in:
- API
- Defined in:
- lib/huntress/authentication.rb
Overview
Deals with authentication flow and stores it within global configuration
Instance Method Summary collapse
-
#login(options = {}) ⇒ Object
Authorize to the Hudu portal and return access_token.
Instance Method Details
#login(options = {}) ⇒ Object
Authorize to the Hudu portal and return access_token
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/huntress/authentication.rb', line 11 def login( = {}) raise ArgumentError, 'client_id not set' unless client_id raise ArgumentError, 'client_secret not set' unless client_secret # pass api key (id) and secret using basic authentication/connection self.token_type = 'Basic' self.access_token = Base64.strict_encode64("#{client_id}:#{client_secret}") # will do sanitty check if token if valid get('/v1/account', ) rescue Faraday::Error => e raise AuthenticationError, e end |