These samples demonstrate basic usage of Bid Manager API v2.
The complete documentation for the Bid Manager API is available from https://developers.google.com/bid-manager/.
For API and client library updates and news, please follow our Google Ads Developers blog: http://googleadsdeveloper.blogspot.com/.
To download the contents of the repository, you can use the command
git clone https://github.com/googleads/googleads-bidmanager-examples
This API uses OAuth2.0.
Follow these steps to enable the API for your Google Cloud Platform project and generate the necessary credentials:
- Visit Google Developers Console to select or create your project.
- From the API Manager → Google APIs screen, activate access to "DoubleClick Bid Manager API".
- Click on "Credentials" in the left navigation menu.
- Click the button labeled "Create credentials" and select "OAuth Client ID".
- Select "Desktop App" as the "Application type", then "Create".
- From the Credentials page, click the "Download OAuth Client" icon under "Actions" next to the client ID you just created and click "Download JSON".
- Save the downloaded file as
client_secrets.json
in your home directory.
These samples support authentication using a service account key. To run samples using a service account, follow these steps after completing steps 1 and 2 from the section above:
- Click on "Credentials" in the left navigation menu.
- Click the button labeled "Create credentials" and select "Service Account".
- Provide a "Service account name", "Service account ID", and "Service account description", then "Create and Continue".
- From the Credentials page, click the new service account email.
- Navigate to the "Keys" tab, click "Add Key", and create a new JSON key, which will download automatically.
- Save the downloaded file as
service_account_key.json
in your home directory. - When starting a sample, include the
--useServiceAccount
argument to designate that you are authenticating with a service account.
Edit DoubleClickBidManagerFactory.java
and change APPLICATION_NAME
Execute the following command:
$ mvn compile
- Setup Eclipse preferences:
- Window > Preferences .. (or on Mac, Eclipse > Preferences)
- Select Maven
- Select "Download Artifact Sources"
- Select "Download Artifact JavaDoc"
- Import the sample project
- "File > Import..."
- Select "Maven > Existing Maven Project" and click "Next"
- Click "Browse" next to "Select root directory", find the sample directory and click "Next"
- Click "Finish"
Once you've checked out the code:
- Run GetLatestReport.java
-
Via the command line, execute the following command:
$ mvn exec:java -Dexec.mainClass="com.google.bidmanager.api.samples.GetLatestReportForQuery" -Dexec.args="--queryId INSERT_QUERY_ID_HERE --outputFile INSERT_OUTPUT_FILE_HERE"
-
Via eclipse, right-click on the project and select Run As > Java Application
-