Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
45.0.0
-----
- Removed `use_cloud_org_for_api_access` setting.
- Removed developer token validation checks.

44.0.0
-----
- Compatibility with v25.1 of the API: https://developers.google.com/google-ads/api/docs/release-notes
Expand Down
6 changes: 0 additions & 6 deletions google_ads_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
# see: https://developers.google.com/identity/protocols/application-default-credentials.
c.use_application_default_credentials = false

# Whether to use the Google Cloud Organization of your Google Cloud
# project instead of developer token to determine your Google Ads API access levels.
# Use this flag only if you are enrolled into a limited pilot that supports
# this configuration.
c.use_cloud_org_for_api_access = false

# You can also authenticate using a service account. If "keyfile" is
# specified below, then service account authentication will be assumed and
# the above authentication fields ignored. Read more about service account
Expand Down
2 changes: 0 additions & 2 deletions lib/google/ads/google_ads/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Config
attr_accessor :developer_token
attr_accessor :login_customer_id
attr_accessor :linked_customer_id
attr_accessor :use_cloud_org_for_api_access
attr_accessor :ads_assistant

attr_accessor :log_level
Expand All @@ -59,7 +58,6 @@ def initialize(&block)
@developer_token = nil
@login_customer_id = nil
@linked_customer_id = nil
@use_cloud_org_for_api_access = false
@ads_assistant = nil

@log_level = nil
Expand Down
4 changes: 0 additions & 4 deletions lib/google/ads/google_ads/google_ads_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ def load_environment_config
# Client library-specific variables
@config.log_level = ENV.fetch("GOOGLE_ADS_RUBY_LOG_LEVEL", @config.log_level)
@config.http_proxy = ENV.fetch("GOOGLE_ADS_RUBY_HTTP_PROXY", @config.http_proxy)
@config.use_cloud_org_for_api_access = ENV.fetch("GOOGLE_ADS_USE_CLOUD_ORG_FOR_API_ACCESS", @config.use_cloud_org_for_api_access)
if @config.use_cloud_org_for_api_access.is_a?(String)
@config.use_cloud_org_for_api_access = @config.use_cloud_org_for_api_access.downcase == "true"
end
@config.ads_assistant = ENV.fetch("GOOGLE_ADS_ASSISTANT", @config.ads_assistant)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ module Ads
module GoogleAds
module Interceptors
class MetadataInterceptor < GRPC::ClientInterceptor
def initialize(developer_token, login_customer_id, linked_customer_id, use_cloud_org_for_api_access, ads_assistant)
def initialize(developer_token, login_customer_id, linked_customer_id, ads_assistant)
super()
@developer_token = developer_token
@login_customer_id = login_customer_id
@linked_customer_id = linked_customer_id
@use_cloud_org_for_api_access = use_cloud_org_for_api_access
@ads_assistant = ads_assistant
end

Expand All @@ -46,7 +45,8 @@ def server_streamer(request:, call:, method:, metadata: {})
private

def update_metadata(metadata)
if !@use_cloud_org_for_api_access
# Add the developer-token header if provided.
if @developer_token && !@developer_token.empty?
metadata[:"developer-token"] = @developer_token
end

Expand Down
6 changes: 3 additions & 3 deletions lib/google/ads/google_ads/service_lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def call
config.developer_token,
config.login_customer_id,
config.linked_customer_id,
config.use_cloud_org_for_api_access,
config.ads_assistant
)

Expand Down Expand Up @@ -89,8 +88,9 @@ def headers
headers[:"linked-customer-id"] = config.linked_customer_id.to_s
end

unless config.use_cloud_org_for_api_access
headers[:"developer-token"] = config.developer_token if config.developer_token
# Add the developer-token header if provided.
if config.developer_token && !config.developer_token.empty?
headers[:"developer-token"] = config.developer_token
end

if config.ads_assistant
Expand Down
2 changes: 1 addition & 1 deletion lib/google/ads/google_ads/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Google
module Ads
module GoogleAds
CLIENT_LIB_NAME = 'gccl'.freeze
CLIENT_LIB_VERSION = '44.0.0'.freeze
CLIENT_LIB_VERSION = '45.0.0'.freeze
VERSION = CLIENT_LIB_VERSION
end
end
Expand Down
22 changes: 0 additions & 22 deletions test/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,4 @@ def test_configure()
assert_equal(developer_token_value, config.developer_token)
assert_equal(ads_assistant_value, config.ads_assistant)
end

def test_use_cloud_org_for_api_access()
config = Google::Ads::GoogleAds::Config.new

refresh_token_value = '1234'
client_id_value = 'abcd'
client_secret_value = '!@#$'
use_cloud_org_for_api_access = true

config.configure do |c|
c.refresh_token = refresh_token_value
c.client_id = client_id_value
c.client_secret = client_secret_value
c.use_cloud_org_for_api_access = use_cloud_org_for_api_access
end

assert_equal(refresh_token_value, config.refresh_token)
assert_equal(client_id_value, config.client_id)
assert_equal(client_secret_value, config.client_secret)
assert_nil(config.developer_token)
assert_equal(true, config.use_cloud_org_for_api_access)
end
end
45 changes: 30 additions & 15 deletions test/test_metadata_interceptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ def setup
"dev_token",
"login_id",
"linked_id",
false,
nil
)
end

def test_adds_developer_token_if_not_cloud_org
def test_adds_developer_token
metadata = {}
mi.request_response(
request: nil,
Expand Down Expand Up @@ -67,16 +66,34 @@ def test_does_not_duplicate_pb_version
assert_equal "gl-ruby/1.2.3 pb/1.2.3", metadata[:"x-goog-api-client"]
end

def test_skips_developer_token_if_cloud_org
mi_cloud = Google::Ads::GoogleAds::Interceptors::MetadataInterceptor.new(
def test_appends_ads_assistant_to_x_goog_api_client
mi_ads_assistant = Google::Ads::GoogleAds::Interceptors::MetadataInterceptor.new(
"dev_token",
"login_id",
"linked_id",
true,
"1.2.3"
)
metadata = { :"x-goog-api-client" => "gl-ruby/1.2.3" }
mi_ads_assistant.request_response(
request: nil,
call: nil,
method: nil,
metadata: metadata
) do
end
assert_includes metadata[:"x-goog-api-client"], "gaada/1.2.3"
assert_includes metadata[:"x-goog-api-client"], "pb/#{Gem.loaded_specs["google-protobuf"].version}"
end

def test_skips_developer_token_if_nil
mi_nil = Google::Ads::GoogleAds::Interceptors::MetadataInterceptor.new(
nil,
"login_id",
"linked_id",
nil
)
metadata = {}
mi_cloud.request_response(
mi_nil.request_response(
request: nil,
call: nil,
method: nil,
Expand All @@ -86,23 +103,21 @@ def test_skips_developer_token_if_cloud_org
assert_nil metadata[:"developer-token"]
end

def test_appends_ads_assistant_to_x_goog_api_client
mi_ads_assistant = Google::Ads::GoogleAds::Interceptors::MetadataInterceptor.new(
"dev_token",
def test_skips_developer_token_if_empty
mi_empty = Google::Ads::GoogleAds::Interceptors::MetadataInterceptor.new(
"",
"login_id",
"linked_id",
false,
"1.2.3"
nil
)
metadata = { :"x-goog-api-client" => "gl-ruby/1.2.3" }
mi_ads_assistant.request_response(
metadata = {}
mi_empty.request_response(
request: nil,
call: nil,
method: nil,
metadata: metadata
) do
end
assert_includes metadata[:"x-goog-api-client"], "gaada/1.2.3"
assert_includes metadata[:"x-goog-api-client"], "pb/#{Gem.loaded_specs["google-protobuf"].version}"
assert_nil metadata[:"developer-token"]
end
end
15 changes: 12 additions & 3 deletions test/test_service_lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ def test_headers_includes_all_when_fully_configured
assert_equal "gaada/v0", headers[:"x-goog-api-client"]
end

def test_headers_excludes_developer_token_when_cloud_org
def test_headers_excludes_developer_token_when_nil
config = Google::Ads::GoogleAds::Config.new do |c|
c.developer_token = "test-dev-token"
c.use_cloud_org_for_api_access = true
c.developer_token = nil
end
lookup = create_lookup(config)

headers = lookup.send(:headers)
assert_nil headers[:"developer-token"]
end

def test_headers_excludes_developer_token_when_empty
config = Google::Ads::GoogleAds::Config.new do |c|
c.developer_token = ""
end
lookup = create_lookup(config)

Expand Down