首页 > 解决方案 > 如何在 python 中使用双击出价管理器(DBM)API

问题描述

我正在尝试使用 google Double click bid manager (DBM) API 来下载报告,我试图在没有手动身份验证的情况下自动执行此操作,但我能找到的只是 DBM 示例的 GitHub 存储库https://github.com /googleads/googleads-bidmanager-examples 此示例打开浏览器进行手动身份验证。有没有办法使用python自动完成?

标签: pythongoogle-apidouble-click-advertising

解决方案


您也可以使用 Google Cloud Platform 服务帐户进行身份验证。

  • 创建服务帐户并创建/下载 JSON 密钥
  • 将服务帐号添加到您要访问的 DBM(现为 Display & Video 360)帐号
  • 使用 Python Google API 客户端库(另请参阅此 Google DV360 教程,身份验证部分相同):
from googleapiclient import discovery
from oauth2client.service_account import ServiceAccountCredentials

# SETTINGS - GOOGLE GENERAL
GOOGLE_JSON_KEYFILE = "<your-keyfile>.json" # Google Cloud Platform Service Account JSON keyfile

# SETTINGS - GOOGLE DV360 API
GOOGLE_DV360_API_VERSION = 'v1'
GOOGLE_DV360_API_SCOPES = ['https://www.googleapis.com/auth/display-video']

# Google D&V360 API service
def get_dv360_service():
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        GOOGLE_JSON_KEYFILE,
        scopes=GOOGLE_DV360_API_SCOPES)

    return discovery.build('displayvideo', GOOGLE_DV360_API_VERSION, credentials=credentials, cache_discovery=False)

dv360_service = get_dv360_service()

#dv360_service.-> get your reports

推荐阅读