Skip to content

Commit

Permalink
Support direct access with Service Account (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrg authored Nov 14, 2023
1 parent 88fc2ee commit 426333c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/google/ads/google_ads/google_ads_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions test/test_google_ads_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 426333c

Please sign in to comment.