Class: G5AuthenticatableApi::Services::TokenInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/g5_authenticatable_api/services/token_info.rb

Direct Known Subclasses

TokenValidator, UserFetcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, headers = {}, warden = nil) ⇒ TokenInfo

Returns a new instance of TokenInfo.



6
7
8
9
10
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 6

def initialize(params={},headers={},warden=nil)
  @params = params || {}
  @headers = headers || {}
  @warden = warden
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 4

def headers
  @headers
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 4

def params
  @params
end

#wardenObject (readonly)

Returns the value of attribute warden.



4
5
6
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 4

def warden
  @warden
end

Instance Method Details

#access_tokenObject



12
13
14
15
16
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 12

def access_token
  @access_token ||= (extract_token_from_header ||
                     params['access_token'] ||
                     warden.try(:user).try(:g5_access_token))
end

#auth_clientObject



22
23
24
25
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 22

def auth_client
  @auth_client ||= G5AuthenticationClient::Client.new(allow_password_credentials: 'false',
                                                      access_token: access_token)
end

#token_dataObject



18
19
20
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 18

def token_data
  auth_client.token_info
end