From 3db521a6148457aa4fba950e64a2e6f034dcf49a Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez Date: Tue, 14 Nov 2023 11:30:58 -0600 Subject: [PATCH 1/2] Support direct access with Service Account --- lib/google/ads/google_ads/google_ads_client.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/google/ads/google_ads/google_ads_client.rb b/lib/google/ads/google_ads/google_ads_client.rb index 6c94a9f65..5641d4050 100644 --- a/lib/google/ads/google_ads/google_ads_client.rb +++ b/lib/google/ads/google_ads/google_ads_client.rb @@ -225,7 +225,6 @@ def get_updater_proc # Provides a Google::Auth::Credentials initialized with a keyfile # specified in the config. def get_service_account_credentials - raise 'config.impersonate required if keyfile specified' unless @config.impersonate keyfile = File.read(@config.keyfile) keyfile = JSON.parse(keyfile) Signet::OAuth2::Client.new( From 50474fe9ad216f026ee6b90bcf099fcc0721cda9 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez Date: Tue, 14 Nov 2023 12:39:30 -0600 Subject: [PATCH 2/2] Update test --- test/test_google_ads_client.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/test_google_ads_client.rb b/test/test_google_ads_client.rb index 6d72929d0..fb25a6c7b 100644 --- a/test/test_google_ads_client.rb +++ b/test/test_google_ads_client.rb @@ -233,12 +233,14 @@ def test_default_to_updater_proc # end # end - def test_keyfile_without_impersonate_raises + def test_crendetials_work_with_service_account_keyfile client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config| - config.keyfile = 'keyfile' + config.keyfile = 'test/fixtures/keyfile.json' end - assert_raises do + assert_raises(OpenSSL::PKey::RSAError) do + # OpenSSL::PKey::RSAError means it read the test file and tried to + # initialize a key with it. Since it's not a valid key, it raises. client.get_credentials end end