This collection of samples written in Python provide usage examples for the AdMob API.
Please make sure that you have pip installed and Python 3.5 or higher.
This API uses OAuth 2.0. See Using OAuth 2.0 to Access Google APIs to learn more.
To get started quickly, follow these steps.
- Visit https://console.developers.google.com to register your application.
- From the API Library, enable the AdMob 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 root directory of the samples.
Execute the following command in the root directory of the AdMob API Python client library samples to install the dependencies.
$ pip install --upgrade google-api-python-client
$ pip install --upgrade google-auth-oauthlib
Before proceeding with the following steps, make sure you are in the root directory of the AdMob API Python client library samples.
-
Open an example and replace the PUBLISHER_ID constant with your Publisher ID.
-
To run the sample, execute the following command.
$ python <sample_name>
-
Complete the authorization steps in the browser.
-
Enter the authorization code in the terminal surrounded by double quotes, for example, "AUTHORIZATION_CODE".
-
Enjoy exploring the AdMob API!