python - 如何在 python 中使用双击出价管理器(DBM)API
问题描述
我正在尝试使用 google Double click bid manager (DBM) API 来下载报告,我试图在没有手动身份验证的情况下自动执行此操作,但我能找到的只是 DBM 示例的 GitHub 存储库https://github.com /googleads/googleads-bidmanager-examples 此示例打开浏览器进行手动身份验证。有没有办法使用python自动完成?
解决方案
您也可以使用 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
推荐阅读
- javascript - How to configure Jest testing framework for use in Nuxt.js?
- javascript - Vue - wrap text selection with span and make style two-way binding?
- javafx - 具有 JFX 11 导入的场景生成器
- android - Recycler View 显示带有空值的卡片
- php - php保存数组多维
- multithreading - 如何将 2 个大型 csv 数据集的一列与 col1+col2 作为键进行比较?
- reactjs - react.js 中的关键警告
- python - 为什么python3命令显示找不到它的错误
- python-3.x - 如何在 docker 更改容器的默认 python 版本?
- sql - 在r中循环sql