Giter Site home page Giter Site logo

allandproust / googleads-shopping-samples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googleads/googleads-shopping-samples

1.0 1.0 1.0 594 KB

Samples for the Content API for Shopping and the Manufacturer Center API

Home Page: https://developers.google.com/shopping-content/

License: Apache License 2.0

Java 22.42% PHP 13.30% Python 19.59% C# 16.42% Ruby 18.52% Go 9.74%

googleads-shopping-samples's Introduction

Samples for the Content API for Shopping and Manufacturer Center API

These code samples are organized by platform or language. Each language directory contains a README with more information about how to run the samples for that particular language. Here, we cover setting up authentication and the common configuration file used by all the samples.

For more information on the APIs, please refer to the documentation for the Content API for Shopping and the Manufacturer Center API.

Choose Your Method of Authentication

Before getting started, check the Getting Started section of the Content API for Shopping documentation. You may want to use service accounts instead to simplify the authentication flow. These samples also support using Google Application Default Credentials.

Setting up authentication for the Manufacturer Center API is similar to the Content API. Just make sure to select the Manufacturer Center API in the API Console. Both APIs can be selected if you wish to try samples for both APIs.

Setting up Authentication and Sample Configuration

  1. Create the directory $(HOME)/shopping-samples to store the configuration.

    If you are unsure where this will be located in your particular setup, then run the samples (following the language-specific README). Errors from the samples related to either this directory or necessary files not existing will provide the full path to the expected directory/files.

    Within this directory, also create the following subdirectories, depending on which API you would like to try:

    • content for the Content API for Shopping
    • manufacturers for the Manufacturer Center API

    Place the files described below in the appropriate subdirectory for the API you want to try.

  2. Set up your desired authentication method.

    If you are using Google Application Default Credentials:

    If you are using a service account:

    • Put the JSON file you downloaded when creating the service account to the file service-account.json in the appropriate API configuration subdirectories.

    If you are using an OAuth2 client ID:

    • Download your OAuth2 client credentials to the file client-secrets.json in the appropriate API configuration subdirectories.

      Note: The samples assume that you are using an OAuth2 client ID that can use a loopback IP address to retrieve tokens. If you are not or are unsure that you are, please visit the [OAuth2.0 for Mobile & Desktop Apps] (https://developers.google.com/identity/protocols/OAuth2InstalledApp) page and follow the instructions there to create a new OAuth2 client ID to use with the samples.

    You can set up multiple authentication methods to try out different flows, but note that the samples will always use the first credentials that can be loaded, in the order:

    1. Google Application Default Credentials
    2. Service accounts credentials
    3. OAuth2 client credentials
  3. Each set of samples uses a different configuration file. For the Content API for Shopping, take the example merchant-info.json from the repository root and copy it into $(HOME)/shopping-samples/content. Next, change its contents appropriately. It contains a JSON object with the following fields:

    Field Type Description
    merchantId number The Merchant Center ID to run samples against.
    accountSampleUser string If non-empty, the email address for the user to add/remove in samples for the Accounts service.
    accountSampleAdWordsCID number If non-zero, the AdWords Customer ID to link/unlink in samples for the Accounts service.

    For the Manufacturer Center API, take the example manufacturer-info.json from the repository root and copy it into $(HOME)/shopping-samples/manufacturers. Next, change its contents appropriately. It contains a JSON object with the following fields:

    Field Type Description
    manufacturerId number The Manufacturer Center ID to run samples against.
    websiteUrl string The URL (without trailing slash) associated with the Manufacturer Center account.

    If using OAuth2 client credentials, once you have authorized access, your token details will be stored in the stored-token.json file in the samples configuration directory. If you have any issues authenticating, remove this file and you will be asked to re-authorize access.

Try Out the Samples

Now that you've configured both the common sample configuration file and set up your authentication credentials, it's time to build and run any of the included samples. As mentioned before, there are language-specific instructions in the READMEs located in each language subdirectory.

Possible Issues

  • When using the Content API for Shopping, if you haven't set up tax settings on your account, you may get an error when running certain samples. If you receive a "missing tax settings" error, set your tax settings in the Merchant Center before trying these samples. Selecting the "Don't charge taxes in the United States" setting is sufficient.

googleads-shopping-samples's People

Contributors

sstrickl avatar yufengg avatar wibblymat avatar josealcerreca avatar anashoommen avatar

Stargazers

YummyX6 avatar

Watchers

James Cloos avatar

Forkers

all-and-proust

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.