Module: Authkeeper::VkAuthApi::Requests::AccessToken

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

Instance Method Summary collapse

Instance Method Details

#fetch_access_token(client_id:, redirect_url:, device_id:, code:, state:, code_verifier:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/authkeeper/vk_auth_api/requests/access_token.rb', line 9

def fetch_access_token(client_id:, redirect_url:, device_id:, code:, state:, code_verifier:)
  post(
    path: 'oauth2/auth',
    body: URI.encode_www_form({
      grant_type: 'authorization_code',
      client_id: client_id,
      device_id: device_id,
      code: code,
      state: state,
      redirect_uri: redirect_url,
      code_verifier: code_verifier
    }),
    headers: {
      'Content-Type' => 'application/x-www-form-urlencoded'
    }
  )
end

#refresh_access_token(client_id:, refresh_token:, device_id:, state:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/lib/authkeeper/vk_auth_api/requests/access_token.rb', line 27

def refresh_access_token(client_id:, refresh_token:, device_id:, state:)
  post(
    path: 'oauth2/auth',
    body: URI.encode_www_form({
      grant_type: 'refresh_token',
      client_id: client_id,
      device_id: device_id,
      refresh_token: refresh_token,
      state: state
    }),
    headers: {
      'Content-Type' => 'application/x-www-form-urlencoded'
    }
  )
end