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



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

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 => e

  raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
end

#token_refresh(token) ⇒ Object

Return an access token from authorization token currrent token



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

def token_refresh(token)
  api_refresh('Token/Refresh', token)
rescue Faraday::BadRequestError => e

  raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
end