Class: IBMCloudSdkCore::JWTTokenManager

Inherits:
Object
  • Object
show all
Defined in:
lib/ibm_cloud_sdk_core/token_managers/jwt_token_manager.rb

Overview

Class to manage JWT Token Authentication

Direct Known Subclasses

CP4DTokenManager, IAMTokenManager

Instance Method Summary collapse

Constructor Details

#initialize(vars) ⇒ JWTTokenManager

Returns a new instance of JWTTokenManager.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ibm_cloud_sdk_core/token_managers/jwt_token_manager.rb', line 12

def initialize(vars)
  defaults = {
    token_info: nil,
    url: nil,
    access_token: nil
  }
  vars = defaults.merge(vars)

  @url = vars[:url]
  @token_info = vars[:token_info]
  @token_name = vars[:token_name]
  @time_to_live = nil
  @expire_time = nil
  @disable_ssl_verification = false
end

Instance Method Details

#tokenObject



28
29
30
31
32
33
34
35
36
# File 'lib/ibm_cloud_sdk_core/token_managers/jwt_token_manager.rb', line 28

def token
  if @token_info.nil? || token_expired?
    token_info = request_token
    save_token_info(token_info: token_info)
    @token_info[@token_name]
  elsif !@token_info.nil?
    @token_info[@token_name]
  end
end