Class: Fortnox::API::Repository::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/fortnox/api/repositories/authentication.rb

Instance Method Summary collapse

Instance Method Details

#renew_tokens(refresh_token:, client_id:, client_secret:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fortnox/api/repositories/authentication.rb', line 9

def renew_tokens(refresh_token:, client_id:, client_secret:)
  body = {
    grant_type: 'refresh_token',
    refresh_token: refresh_token
  }

  response = HTTParty.post(Fortnox::API.config.token_url,
                           headers: headers(client_id, client_secret),
                           body: body)

  validate_response(response)

  parsed_response_to_hash(response.parsed_response)
end