Class: VivaWallet::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/viva_wallet/authentication.rb

Class Method Summary collapse

Class Method Details

.oauthObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/viva_wallet/authentication.rb', line 7

def oauth
  RestClient::Request.new({
                            method: :post,
                            url: VivaWallet. + 'connect/token',
                            payload: {grant_type: 'client_credentials'},
                            headers: {
                              content_type: 'application/x-www-form-urlencoded',
                              Authorization: "Basic #{VivaWallet.client_base64}"
                            }
                          }).execute do |response, request, result|
    str_response = response.to_str
    str_response.blank? ? '' : JSON.parse(str_response)
  end
end