Module: Fullscriptapi::AuthenticationEndpoints::RefreshToken

Included in:
Fullscriptapi::AuthenticationEndpoints
Defined in:
lib/fullscriptapi/authentication_endpoints/refresh_token.rb

Instance Method Summary collapse

Instance Method Details

#refresh_tokenObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fullscriptapi/authentication_endpoints/refresh_token.rb', line 6

def refresh_token
  response = Excon.post("#{get_server}/api/oauth/token",
    headers: {
      "Content-Type": "application/json"
    },
    body: {
      grant_type: "refresh_token",
      client_id: client_id,
      client_secret: secret,
      redirect_uri: redirect_uri,
      refresh_token: token.refresh_token
    }.to_json
  )
  
  body = JSON.parse(response.body)
  
  use_token(body["oauth"])
end