Class: Haipa::Client::ApplicationTokenProvider

Inherits:
MsRest::TokenProvider
  • Object
show all
Defined in:
lib/haipa_rest/credentials/application_token_provider.rb

Overview

Class that provides access to authentication token.

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_key, identity_endpoint) ⇒ ApplicationTokenProvider

Creates and initialize new instance of the ApplicationTokenProvider class.



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/haipa_rest/credentials/application_token_provider.rb', line 47

def initialize(client_id, client_key, identity_endpoint)
  fail ArgumentError, 'Client id cannot be nil' if client_id.nil?
  fail ArgumentError, 'Client key cannot be nil' if client_key.nil?
  fail ArgumentError, 'Identity_endpoint url cannot be nil' if identity_endpoint.nil?

  @client_id = client_id
  @client_key = client_key
  @identity_endpoint = identity_endpoint

  @expiration_threshold = 5 * 60
end

Instance Method Details

#get_authentication_headerString

Returns the string value which needs to be attached to HTTP request header in order to be authorized.



64
65
66
67
# File 'lib/haipa_rest/credentials/application_token_provider.rb', line 64

def get_authentication_header
  acquire_token if token_expired
  "#{token_type} #{token}"
end