Module: Authkeeper::VkAuthApi::Requests::FetchAccessToken

Included in:
Client
Defined in:
app/lib/authkeeper/vk_auth_api/requests/fetch_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/fetch_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