首页 > 解决方案 > 从 google adwords API 获取 AuthenticationError.OAUTH_TOKEN_INVALID

问题描述

我已经使用此处描述的步骤设法生成了 developer_token、oauth client_id、oauth client_secret 和 oauth refresh_token,并且我已经在 googleads.yaml 中设置了它们的值。由于 UI 中的问题(与 google adwords 产品团队一起打开了一个线程) ,我没有为 client_customer_id 设置任何值。但是,当我到达这一步时,我得到了 AuthenticationError.OAUTH_TOKEN_INVALID。我正在使用 python 3.7、googleads 23.0.1 和来自此处的代码示例。

我正在运行的代码:

client = adwords.AdWordsClient.LoadFromStorage(f'{os.getcwd()}/oauth/googleads.test.yaml')
# Initialize appropriate service.
campaign_service = client.GetService('CampaignService', version='v201809')

# Construct selector and get all campaigns.
offset = 0
selector = {
    'fields': ['Id', 'Name', 'Status'],
    'paging': {
        'startIndex': str(offset),
        'numberResults': str(PAGE_SIZE)
    }
}

more_pages = True
while more_pages:
    page = campaign_service.get(selector) # this is the line which raises the exception

有什么建议么?

非常感谢你的帮助,塔尔

标签: google-ads-api

解决方案


推荐阅读