Module: Integra365::Authentication

Included in:
API
Defined in:
lib/integra365/authentication.rb

Overview

Deals with authentication flow and stores it within global configuration

Instance Method Summary collapse

Instance Method Details

#token(options = {}) ⇒ Object Also known as: login

Authorize to the Integra365 portal and return access_token



9
10
11
12
13
14
15
# File 'lib/integra365/authentication.rb', line 9

def token(options = {})
  raise ConfigurationError.new 'Client id and/or secret not configured' unless self.username && self.password

  api_auth('Token', options)
rescue Faraday::BadRequestError, Faraday::UnauthorizedError => e
  raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
end

#token_refresh(token) ⇒ Object

Return an access token from authorization token currrent token



20
21
22
23
24
# File 'lib/integra365/authentication.rb', line 20

def token_refresh(token)
  api_refresh('Token/Refresh', token)
rescue Faraday::BadRequestError, Faraday::UnauthorizedError => e
  raise AuthenticationError.new 'Unauthorized; response #{e}'
end