As many of you are well aware, the DFP API Playground is a great tool to explore the DFP API. With it, you can easily test PQL statements and examine the JSON equivalent of the objects you fetch. Best of all, it acts as a full reference implementation of how you should integrate the API with App Engine, touching on features such as OAuth2 authentication, task queues, and channels.

Now, we are announcing the new GitHub project for the DFP API Playground, featuring all the benefits of being hosted on GitHub, improved getting started instructions, and revamped project downloads.

Taking it for a spin

The first thing you’ll notice when visiting the project is that we’ve made it incredibly easy to get up and running.

With Maven

If you are a Maven user, it’s as simple as modifying the appengine-web.xml file and running
 mvn appengine:devserver

We’ve also included an m2e project so developing with Eclipse is easier than ever. Just import the extracted dfp-playground-maven-project download into Eclipse, modify the appengine-web.xml file (in the src/main/webapp/WEB-INF directory), and run the DevAppServer.launch profile in the eclipse-launch-profiles folder.

With Google Plugin for Eclipse

We also heard you loud and clear that not everyone uses Maven, so we’ve added a Google Plugin for Eclipse project download which includes all jar dependencies. As with the Maven project, just extract the dfp-playground-jars-and-google-eclipse-plugin-project download, import it into Eclipse, add Google App Engine functionality to the project, modify the appengine-web.xml file (in the war/WEB-INF directory), and run the project like any other App Engine project.

If you’d like to learn more, take a look at the README. As always, we are open to any feedback, so please don’t hesitate to leave us any feature requests in the issues section. Also, if you’d like to contribute to the project, we welcome any patches (just make sure you become an official contributor first).

In the coming months, we’ll be adding even more functionality to the application, so stay tuned and happy hacking!


The AdWords API Python Google App Engine demo has been updated to use v201109 (and clientCustomerId) and now has its source control hosted at the new project site.

In addition, we are happy to announce the release of a new Python Google App Engine demo - this one demonstrating AdHoc reports running on Google App Engine using OAuth 1.0a for the authentication. This demo allows you to select as many or as few child accounts as you wish to run a report against and will download the reports asynchronously using a Task Queue one by one. Reports are stored in the Google App Engine Blobstore and can be downloaded by the user once they have been processed.

The new demo also shows how to perform the OAuth flow in a web application context and how to store the oauth_token and oauth_token_secret in the Google App Engine datastore. OAuth is used both to query the API for a list of accounts as well as to download the reports.

You can download the Google App Engine demo and use the Python Development Google App Engine Server to play around with the code without the need for an existing Google App Engine account. If you have any questions or would like to discuss this new demo, please post on the forum.


We are excited to start discussing how to use the DFP API from within the Google App Engine (Java) environment. This first blog post in the series focuses on setting up your environment and understanding how to use the API from App Engine. Future posts in this series will build upon the same project to create a sample application. Ultimately, you will be able to make DFP information more accessible within your organization, while also leveraging the ease of scale and deployability that comes with creating applications on Google App Engine.

Setting up your environment

For simplicity sake we will focus on utilizing Eclipse and the Google App Engine Plugin available for Eclipse. Information about setting them up can be found here. If you prefer a different environment setup, you can always view the Getting Started Guide for App Engine for more information.

Create an App Engine project

You’ll need a place to do your coding so create an App Engine project in a similar manner to the screenshots below.

Note: If you would like to download all of the source code in this blog post to follow along you can do so as a tarball or you can browse the code base from our svn repository.


The App Engine Java environment requires JAX-WS when dealing with SOAP interfaces like DFP API so you won’t be able to use the normal Java client library. You’ll need to download this client login auth file to help with authentication. Place this file in your project’s src directory. Next, you’ll need a jar and a wsdl file that we’ve compiled with JAX-WS; place them in the WEB-INF/lib and WEB-INF directory, respectively. See the files highlighted in their respective locations below.

Write some code

Now that you’re set up, it’s time to write some code that uses the DFP API. This first snippet of code performs some setup for your App Engine Servlet.

   * Perform initialization of servlet and cached resources used to
   * access DFP API.
  public void init(ServletConfig config) throws ServletException {

    // Generate an authToken.
    try {
      authToken = regenerateAuthToken();
    } catch (Exception exception) {
      throw new ServletException("Could not generate an Auth Token.",

   * Regenerate the client login auth token that the servlet uses.
   * @throws Exception
  public synchronized String regenerateAuthToken() throws Exception {
    ClientLoginAuth clientLoginAuth = new ClientLoginAuth(EMAIL_ADDRESS, 
    return clientLoginAuth.getAuthToken();

This next snippet of code handles the actual web browser requests.

  public void doGet(HttpServletRequest req, HttpServletResponse resp) 
      throws ServletException {
    try {
      // Retrieve an object handle to our network service.
      NetworkService networkService = new NetworkService();
      NetworkServiceInterface networkServiceInterface =

      // Prepare header object to make server call
      SoapRequestHeader requestHeader = new SoapRequestHeader();
      requestHeader.setApplicationName("Hello World");
      ClientLogin clientLogin = new ClientLogin();

      // Make protected call to the server.
      String rootAdUnitId = "";
      Network currentNetwork = networkServiceInterface.getCurrentNetwork(
          requestHeader, null);
      // Extract data from object returned from server.
      rootAdUnitId = currentNetwork.getEffectiveRootAdUnitId();

      resp.getWriter().println("Hello, world. Your root ad unit id is: "
          + rootAdUnitId);
    } catch (Exception e) {
      // Perform exception handling.
      throw new ServletException("Error occurred. Check logs for specific "
          " details about the error.");

This particular code snippet retrieves the root ad unit for our network whenever someone accesses the application. You can view the full sample servlet code here.


To make sure your code works, let’s deploy the project locally. Right-click on your project and then choose “Run” and select the “Web Application” option from the submenu. This will deploy your code to a locally running App Engine server. The console will display the URL to access the application (usually http://localhost:8888/). Clicking on this link and then the subsequent servlet link should return a page similar to this.

Next Time

Next time, we’ll extend the project to do some background processing and start using some other services from the DFP API.


We really hope you didn’t have an issue, but if you did there is a troubleshooting README file included in the sample code.

Let us know if you have any questions, and happy holidays!