Method: GoogleWallet::Authentication#access_token

Defined in:
lib/google_wallet/authentication.rb

#access_tokenObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/google_wallet/authentication.rb', line 13

def access_token
  if @credentials
    begin
      credentials = Google::Auth::ServiceAccountCredentials.make_creds(
        json_key_io: StringIO.new(@credentials.to_json),
        scope: SCOPE
      )

      credentials.fetch_access_token!
      credentials.access_token
    rescue StandardError => e
      puts "Error while fetching access token: #{e.message}"
      nil
    end
  else
    puts "No credentials provided."
    nil
  end
end