Module: Tipalti::Actions::Token

Included in:
Client
Defined in:
lib/tipalti-ruby/actions/token.rb

Instance Method Summary collapse

Instance Method Details

#token_refreshObject

rubocop:disable Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tipalti-ruby/actions/token.rb', line 6

def token_refresh # rubocop:disable Metrics/MethodLength
  response = connection_token.post("/connect/token",
                                   {
                                     client_id: @client_id,
                                     client_secret: @client_secret,
                                     grant_type: "refresh_token",
                                     refresh_token: @refresh_token,
                                     code_verifier: @code_verifier
                                   },
                                   {
                                     body: :form,
                                     content_type: "application/x-www-form-urlencoded"
                                   })

  # Refresh the client values inline
  @access_token   = response["access_token"]
  @refresh_token  = response["refresh_token"]

  # Give a chance to the invoker of the client to do something with the response
  response
end