Installer la bibliothèque cliente Python
Pour installer la bibliothèque cliente Python dans votre environnement local :
- Extrayez l'archive tar de la bibliothèque cliente Python.
Exécutez la commande suivante dans le même répertoire :
python -m pip install .
Suivez les instructions du terminal pour terminer l'installation.
Configuration à l'aide d'un fichier YAML
Vous pouvez spécifier un fichier YAML à utiliser lors de l'initialisation du client, qui contient les informations d'authentification nécessaires pour effectuer des requêtes. Ce fichier est consulté lorsqu'un client est initialisé à l'aide de la méthode load_from_file
.
Suivez l'exemple ci-dessous lorsque vous créez le fichier YAML pour spécifier le jeton d'actualisation, l'ID client et le code secret du client.
Pour spécifier l'emplacement du fichier search-ads-360.yaml
, vous pouvez transmettre le chemin d'accès sous forme de chaîne à la méthode lorsque vous l'appelez :
from util_searchads360 import SearchAds360Client
client = SearchAds360Client.load_from_file("path/to/search-ads-360.yaml")
Si vous ne spécifiez pas de chemin d'accès, la bibliothèque recherche le fichier dans votre répertoire $HOME
:
from util_searchads360 import SearchAds360Client
client = SearchAds360Client.load_from_file()
Champs de configuration
La configuration de la bibliothèque cliente accepte les champs suivants.
Champs généraux :
refresh_token
: votre jeton d'actualisation OAuth.client_id
: votre ID client OAuth.client_secret
: votre code secret client OAuth.login_customer_id
: consultez la documentation sur login-customer-id.
Clés compatibles pour les flux d'applications Web et pour ordinateur
Si vous utilisez le flux d'application pour ordinateur ou Web, les clés compatibles sont les suivantes :
# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
client_id: INSERT_CLIENT_ID_HERE
# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
client_secret: INSERT_CLIENT_SECRET_HERE
# Renewable OAuth credential associated with 1 or more Search Ads accounts.
refresh_token: INSERT_REFRESH_TOKEN_HERE
# Required for manager accounts only: Specify the login customer ID used to
# authenticate API calls. This will be the customer ID of the authenticated
# manager account. You can also specify this later in code if your application
# uses multiple manager account + OAuth pairs.
#
# login_customer_id: INSERT_LOGIN_CUSTOMER_ID_HERE