Вопрос

I would like to access my Google Affiliate Network product feed via the Google search API for shopping. I would like to do this from a backend Python library i'm developing. Has anyone done something like this?

I have the following:

  • A Google account
  • Enabled Search API for Shopping in the Google API Console and got an API key (for server apps) and a client ID + client secret (for installed applications).
  • A GAN account and got the pid.
  • Several advertiser who approved me so i have products available in my product feed.

OAuth2 Python Code:

from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run
from oauth2client.django_orm import Storage
from models import CredentialsModel 

storage = Storage(CredentialsModel, 'name', 'GAN Reporting', 'credentials')
credentials = storage.get()

if credentials is None or credentials.invalid == True:
    flow = OAuth2WebServerFlow(
        client_id=MyClientID,
        client_secret=MyClientSecret,
        scope='https://www.googleapis.com/auth/shoppingapi',
        user_agent='cleverblocks/1.0',
        access_type='offline')
    credentials = run(flow, storage)

http = httplib2.Http()
credentials.authorize(http)
client = build('shopping', 'v1', http=http,
    developerKey=MyAPIKey)
resource = client.products()
request = resource.list(source='gan:MyGANPid', country='US')
return request.execute()

Running this i get back the following error (HttpError 412):

no advertisers are registered for the given publisher

The user I am using to authenticate is listed on the GAN->settings->users section.

I've been hacking at this from all directions to the point where I'm now starting to think this API is broken. Has anyone managed to access GAN product feed via the Search API for Shopping?

Any help is appreciated.

Это было полезно?

Решение

Finally got the above oAuth code to work.

The missing step was in the GAN console, under Subscriptions->Product Feed, to set an FTP subscription for all your advertisers. I used dummy FTP credentials.

Without this step you will get the above error.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top