Module: PaypalAPI::Authentication::APIs
- Included in:
- PaypalAPI::Authentication, PaypalAPI::Authentication
- Defined in:
- lib/paypal-api/api_collections/authentication.rb
Overview
Common methods for PayplaAPI::Authentication class and client.authentication instance
Instance Method Summary collapse
-
#generate_access_token(query: nil, body: nil, headers: nil) ⇒ Response
Generates access token.
Instance Method Details
#generate_access_token(query: nil, body: nil, headers: nil) ⇒ Response
Generates access token.
Default headers are:
{ "content-type" => "application/x-www-form-urlencoded", "authorization" => "Basic <TOKEN>" }
Default body is:
{grant_type: "client_credentials"}
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/paypal-api/api_collections/authentication.rb', line 41 def generate_access_token(query: nil, body: nil, headers: nil) body ||= {grant_type: "client_credentials"} default_headers = { "content-type" => "application/x-www-form-urlencoded", "authorization" => "Basic #{["#{client.env.client_id}:#{client.env.client_secret}"].pack("m0")}" } client.post(PATH, query: query, body: body, headers: merge_headers!(default_headers, headers)) end |