Class: PayuPl::Authorize::OAuthToken

Inherits:
Operations::Base show all
Defined in:
lib/payu_pl/authorize/oauth_token.rb

Instance Method Summary collapse

Instance Method Details

#call(grant_type: "client_credentials") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/payu_pl/authorize/oauth_token.rb', line 6

def call(grant_type: "client_credentials")
  form = {
    grant_type: grant_type,
    client_id: client.client_id,
    client_secret: client.client_secret
  }

  response = transport.request(
    :post,
    Endpoints::OAUTH_TOKEN,
    headers: { "Content-Type" => "application/x-www-form-urlencoded" },
    form: form,
    authorize: false
  )

  token = response.fetch("access_token")
  client.access_token = token
  response
end