python - Adwords API - AuthorizationError.USER_PERMISSION_DENIED - Python
问题描述
我正在尝试使用 Google Adwords 测试 API。我正在尝试连接到 Google Adwords API,但我不断收到以下错误:
googleads.errors.GoogleAdsServerFault: [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]
为了获得开发者 API 密钥,我创建了一个 Google Adwords 生产帐户。然后,我创建了一个 Google Adwords Manager 测试帐户并设法获得了 Oauth Client id 和 Secret Id。然后我使用了Google Oauth 2.0 Playground来获取刷新令牌。我的 google_adwords.yaml 文件现在看起来像这样:
# AdWordsClient configurations
adwords:
#############################################################################
# Required Fields #
#############################################################################
developer_token: **DEVELOPER TOKEN FROM PRODUCTION ACCOUNT PASTED HERE**
#############################################################################
# Optional Fields #
#############################################################################
client_customer_id: **CLIENT CUSTOMER ID FROM MANAGER TEST ACCOUNT PASTED HERE**
# user_agent: INSERT_USER_AGENT_HERE
# partial_failure: True
# validate_only: True
#############################################################################
# OAuth2 Configuration #
# Below you may provide credentials for either the installed application or #
# service account flows. Remove or comment the lines for the flow you're #
# not using. #
#############################################################################
# The following values configure the client for the installed application
# flow.
client_id: **CLIENT ID FROM MANAGER TEST ACCOUNT PASTED HERE**
client_secret: **CLIENT CUSTOMER SECRET FROM MANAGER TEST ACCOUNT PASTED HERE**
refresh_token: **REFRESH TOKEN FROM OAUTH PLAYGROUND ON BEHALF OF MANAGER TEST ACCOUNT PASTED HERE**
# The following values configure the client for the service account flow.
# path_to_private_key_file: INSERT_PATH_TO_JSON_KEY_FILE_HERE
# delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT
#############################################################################
# ReportDownloader Headers #
# Below you may specify boolean values for optional headers that will be #
# applied to all requests made by the ReportDownloader utility by default. #
#############################################################################
# report_downloader_headers:
# skip_report_header: False
# skip_column_header: False
# skip_report_summary: False
# use_raw_enum_values: False
我的 Python 代码如下所示:
# -*- coding: utf-8 -*-
from googleads import adwords
adwords_client = adwords.AdWordsClient.LoadFromStorage('C:\Python36\google_adwords.yaml')
ad_group_service = adwords_client.GetService('TargetingIdeaService', version='v201802')
selector = {
'ideaType': 'KEYWORD',
'requestType': 'IDEAS'
}
page = ad_group_service.get(selector)
print (page)
有谁知道我要去哪里错了?我认为我的 YAML 文件有问题,但不能完全确定它可能是什么。提前致谢!
解决方案
推荐阅读
- ios - 从 for 循环将最后一个元素添加到数组
- docker - 无法使用 Windows Docker-Compose 绑定卷
- c++ - 来自 elf 文件的模型内存
- node.js - 如何创建一个中间件来响应 express 上的所有静态文件请求?
- java - 在 assertEquals 中使用方括号的 Java 事件驱动开发问题
- swift - Swift Eureka:更新 Eureka tableView 的样式
- html - Bootstrap 4表单字段未水平对齐
- amazon-web-services - 如何使用 lambda 函数 AWS SAM 添加访问密钥的策略
- python - 从 Amazon Product Advertising API 5.0 中提取“About this item”
- react-native - 没有结果 react-native-searchable-dropdown