Module: Authkeeper::AvitoAuthApi::Requests::AccessToken

Included in:
Client
Defined in:
app/lib/authkeeper/avito_auth_api/requests/access_token.rb

Instance Method Summary collapse

Instance Method Details

#fetch_access_token(client_id:, client_secret:, code:, return_raw_response: false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/lib/authkeeper/avito_auth_api/requests/access_token.rb', line 7

def fetch_access_token(client_id:, client_secret:, code:, return_raw_response: false)
  form_post(
    path: 'token',
    body: {
      grant_type: 'authorization_code',
      client_id: client_id,
      client_secret: client_secret,
      code: code
    },
    headers: {
      'Content-Type' => 'application/x-www-form-urlencoded'
    },
    return_raw_response: return_raw_response
  )
end

#refresh_access_token(client_id:, client_secret:, refresh_token:, return_raw_response: false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/lib/authkeeper/avito_auth_api/requests/access_token.rb', line 23

def refresh_access_token(client_id:, client_secret:, refresh_token:, return_raw_response: false)
  form_post(
    path: 'token',
    body: {
      grant_type: 'refresh_token',
      client_id: client_id,
      client_secret: client_secret,
      refresh_token: refresh_token
    },
    headers: {
      'Content-Type' => 'application/x-www-form-urlencoded'
    },
    return_raw_response: return_raw_response
  )
end