BingAds 客户端状态,oauth_web_auth_code_grant

BingAds Client State, oauth_web_auth_code_grant

我想通过 bingads API 从我的 BingAds 中获取我的自定义 "Reports" 数据。我正在使用 KeywordsAds.py 示例,它可能不正确。但是,我的问题始于身份验证,我似乎无法找到所需的所有身份验证输入。我缺少类似的例子,所以我知道我是否插入了正确的数据:

authorization_data=AuthorizationData(
    account_id='123456789', --instead of just None
    customer_id='123456789', --instead of just None
    developer_token='12345A1234567891', --instead of just DeveloperTokenGoesHere
    authentication='OAuthWebAuthCodeGrant', --instead of just None

)

1) 对于上面的代码,WebAPI需要选择什么authentication? (2) 对于我提出的问题,我需要使用 WebAPI,还是 Web 平台更有用?

CLIENT_ID='ClientIdGoesHere'
CLIENT_STATE='ClientStateGoesHere'

3) 什么是Client_State?这个词我做了google,但是没有找到解释。要插入什么值 could/need?

最后,我没有在示例代码中找到 client_secret 和 redirection_uri,但在 Getting Started page for Python on Bing:

中有说明
oauth_web_auth_code_grant = OAuthWebAuthCodeGrant(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    redirection_uri=REDIRECTION_URI

这个有必要填写吗?

所以,我已经解决了前一段时间的问题。

第一个代码块是正确的,这就是示例的样子,只需替换 account_idcustomer_id 中的数字即可。 developer_token 有我的问题中显示的数字和字母。对于 authentication,使用 'OAuthWebAuthCodeGrant'.

回答问题 1:WebAPI 有效,(2) CLIENT_ID 使用 WebAPI 的 Application ID URIapi://.

之后的部分

Q3:CLIENT_STATE我原样留下的,不需要了。

不需要问题的最后一个代码块。

如果您是像我这样的初学者并且需要一些帮助,我制作了一个快速而简陋的 Python 模板。它将我的报告下载到 CSV,然后我将它导入到 Pandas,在那里我清理数据集,然后我再次将它写出到 CSV,最后将它上传到 Google Analytics here