Class: CapitalOnTap::Auth

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capital_on_tap/auth.rb

Constant Summary collapse

TOKEN_PATH =
'/connect/token'
DEFAULT_GRANT_TYPE =
'password'
REFRESH_GRANT_TYPE =
'refresh_token'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.obtain_tokenObject



22
23
24
# File 'lib/capital_on_tap/auth.rb', line 22

def self.obtain_token
  new.obtain_token
end

.refresh_access_token(refresh_token) ⇒ Object



18
19
20
# File 'lib/capital_on_tap/auth.rb', line 18

def self.refresh_access_token(refresh_token)
  new.refresh_access_token(refresh_token)
end

Instance Method Details

#obtain_tokenObject

Requests a new token. The response will be something like:

scope: 'profile offline_access',
token_type: 'Bearer',
access_token: '<access_token>',
expires_in: 1200,
refresh_token: '<refresh_token>'



35
36
37
# File 'lib/capital_on_tap/auth.rb', line 35

def obtain_token
  token_request(token_params)
end

#refresh_access_token(refresh_token) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/capital_on_tap/auth.rb', line 39

def refresh_access_token(refresh_token)
  return {} unless refresh_token

  refresh_params = token_params(grant_type: REFRESH_GRANT_TYPE, refresh_token: refresh_token)

  token_request(refresh_params)
end