- Browse Source
- Main file to run all examples: AdSenseSample.java
- Visit the Google Cloud console
- If necessary, sign in to your Google Account, select or create a project, and agree to the terms of service. Click Continue.
- From the API Library, enable the AdSense Management API.
- Click on APIs & Services > Credentials in the left navigation menu.
- Click CREATE CREDENTIALS > OAuth client ID.
- Select Desktop app as the application type, give it a name, then click Create.
- From the Credentials page, click Download JSON next to the client ID you
just created and save the file as
client_secrets.json
in the src/main/resources/ directory. If you skip this step, when trying to run the sample you will get a401 INVALID_CLIENT
error in the browser.
Prerequisites: install Java (version 7 or later), and
Maven. You may need to set your
JAVA_HOME
.
cd *[someDirectory]*
git clone https://github.com/googleads/googleads-adsense-examples
cd googleads-adsense-examples/v2/java/
cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
mvn compile
mvn -q exec:java
To enable logging of HTTP requests and responses (highly recommended when
developing), please take a look at the logging.properties
file.