简体   繁体   English

并行访问Google AdWords数据

[英]Accessing Google AdWords data in parallel

Given 特定

I'm developing two different applications that utilize the same AdWords API access credentials. 我正在开发两个使用相同AdWords API访问凭据的不同应用程序。 Bot application are only intended to gather/analyse data from the API. Bot应用程序仅用于从API收集/分析数据。

Applications #1 and #2 take roughly 1 hour to complete the process of getting/analysing the data from API. #1和#2应用程序大约需要1个小时才能完成从API获取/分析数据的过程。

I'm using: 我正在使用:

  1. my own AdWords account, 我自己的AdWords帐户,
  2. ClientLogin authentication method, ClientLogin身份验证方法,
  3. ruby language. 红宝石语言。

The problem 问题

Sometimes both timesframes (for app #1 and #2) can overlap, and I start to get tons of these error: 有时两个时间段(对于应用程序1和应用程序2)可能会重叠,而我开始收到大量此类错误:

AdwordsApi::Errors::ReportXmlError: HTTP code: 400, error type: 'AuthorizationError.USER_PERMISSION_DENIED'

The next sequence of events leads to a problem: 下一个事件序列导致一个问题:

  1. App #1 asks for auth token from Google and caches it once one received, 应用程式1要求Google的验证权凭证,并在收到后将其缓存,
  2. App #1 starts data ingestion process using the token, App#1使用令牌启动数据提取过程,
  3. App #2 asks for auth token from Google and caches it once one received, 应用程式2会要求Google寄出授权凭证,并在收到一个后将其缓存,
  4. App #2 starts data ingestion process using the token, App#2使用令牌启动数据提取过程,
  5. App #1 asks for another portion of data from AdWords API, but because of item 3, the auth token for App 1 got invalidated, and app starts choking because of the above error. App#1向AdWords API询问数据的另一部分,但是由于第3项,App 1的身份验证令牌无效,并且由于上述错误,App开始窒息。

So the question is: is there a way to do such a setup to enable both applications accessing the AdWords API at the very same time without token interference/invalidation ? 因此,问题是: 是否可以进行这样的设置,以使两个应用程序同时访问AdWords API而不会造成令牌干扰/无效

We have many apps which follow the same pattern as you have described but we don't experience token invalidations. 我们有许多应用程序遵循您所描述的相同模式,但是我们不会遇到令牌失效的情况。

AdwordsApi::Api.new(credentials).authorize

We cache the token that's returned there and then re-use it for subsequent requests, but the credentials we use are shared by many apps, the token is only used by one app. 我们缓存返回的令牌,然后将其用于后续请求,但我们使用的凭据由许多应用程序共享,令牌仅由一个应用程序使用。 We cache it for 12 hours then expire it, causing a new one to be issued. 我们将其缓存12个小时,然后将其过期,从而导致发布新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM