【问题标题】:I can't get Google Adwords Customers Campagin inform我无法获取 Google Adwords 客户活动通知
【发布时间】:2020-10-28 17:39:49
【问题描述】:

我想构建一个 Web 应用程序。客户可以使用网络应用程序来读取他们的 google Adwrods 帐户信息(活动或预算)。

首先,我使用 oath2 获取客户端的 refresh_token 和 access_token。 使用 refresh_token,我可以通过 (https://github.com/googleads/google-ads-ruby) 获取客户端下的所有 adwords id

client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config|
  config.client_id = "client_id"
  config.client_secret = "client_secret"
  config.refresh_token = "refresh_token"
  config.login_customer_id = "XXX-XXX-XXXX"
  config.developer_token = "XXXXXXXXXXXXXXXX"
end
accessible_customers = client.service.customer.list_accessible_customers().resource_names

当我想获取客户 Adword 帐户信息时,

resource_name = client.path.customer("XXXXXXXX")
customer = client.service.customer.get_customer(resource_name: resource_name)

我收到“GRPC::Unauthenticated: 16:Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential”,但配置文件不能让我设置 access_token。

那么,我在哪里可以设置客户端的 access_token,或者我错过了哪一步?

【问题讨论】:

  • 欢迎来到 SO!请包含更多代码,向我们展示您设置client 并调用client.service.customer 的整个文件
  • 哈哈,我想是这样,这意味着finallyXDDD以上是我所有的客户端配置设置。 login_customer_id 是我的adwords manager account id,developer_token 是manager account 的developer_token,refresh_token 是client auth 拿到的。当我得到customer_id时,我刚刚调用了client.service.customer,有没有我之前调用过的方法?

标签: ruby-on-rails google-ads-api


【解决方案1】:

错误告诉您client 没有正确设置。这可能是从谷歌帐户到错误信息的一堆问题。我会检查并确保您在Google::Ads::GoogleAds::GoogleAdsClient.new 中传递的所有信息都是正确的。

另外,您只需要为经理帐户传递“login_customer_id”,这听起来不像您是经理帐户。

来自https://github.com/googleads/google-ads-ruby/blob/master/google_ads_config.rb

  # Required for manager accounts only: Specify the login customer ID used to
  # authenticate API calls. This will be the customer ID of the authenticated
  # manager account. If you need to use different values for this field, then
  # make sure fetch a new copy of the service after each time you change the
  # value.
  # c.login_customer_id = 'INSERT_LOGIN_CUSTOMER_ID_HERE'

【讨论】:

  • 嗨@nzajt,我将我的 AdWords 经理帐户 ID 传递给了 login_customer_id,不是吗?
  • 顺便说一下,我的 developer_token 是我的 adwords manager 帐户的 developer_token
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多