简体   繁体   中英

Accessing Google AdWords data in parallel

Given

I'm developing two different applications that utilize the same AdWords API access credentials. Bot application are only intended to gather/analyse data from the API.

Applications #1 and #2 take roughly 1 hour to complete the process of getting/analysing the data from API.

I'm using:

  1. my own AdWords account,
  2. ClientLogin authentication method,
  3. ruby language.

The problem

Sometimes both timesframes (for app #1 and #2) can overlap, and I start to get tons of these error:

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,
  2. App #1 starts data ingestion process using the token,
  3. App #2 asks for auth token from Google and caches it once one received,
  4. App #2 starts data ingestion process using the token,
  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.

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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