【发布时间】: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