0

我正在努力使用 bings api python 来获取所有活动。

ALL_CAMPAIGN_TYPES = ['Audience DynamicSearchAds Search Shopping']

 authorization_data = AuthorizationData(
        account_id=None,
        customer_id=None,
        developer_token=env('DEVELOPER_TOKEN'),
        authentication=None,
    )
    campaign_service = ServiceClient(
        service='CampaignManagementService',
        version=13,
        authorization_data=authorization_data,
        environment=env('ENVIRONMENT'),
    )
 campaigns = campaign_service.GetCampaignsByAccountId(
        AccountId="xxxxxxx", CampaignType=ALL_CAMPAIGN_TYPES)

它给了我错误:suds.WebFault:服务器引发错误:'无效的客户端数据。检查 SOAP 故障详细信息以获取更多信息。TrackingId:1ee709e5-b0d5-4b82-a19e-65001a80789e。

请帮我摆脱这个。

4

1 回答 1

0

这是一个最小的例子:

from bingads import (
    AuthorizationData,
    OAuthAuthorization,
    OAuthWebAuthCodeGrant,
    ServiceClient,
)

oauth_web_auth_code_grant = OAuthWebAuthCodeGrant(
    client_id="YOURCLIENTID",
    client_secret="YOURCLIENTSECRET",
    redirection_uri=None,
)
refresh_token = "SOMEREFRESHTOKEN"
oauth_tokens = oauth_web_auth_code_grant.request_oauth_tokens_by_refresh_token(
    refresh_token
)

authorization_data = AuthorizationData(
    developer_token="YOURDEVELOPERTOKEN",
    authentication=OAuthAuthorization(
        client_id=oauth_web_auth_code_grant.client_id,
        oauth_tokens=oauth_tokens,
    ),
)

customermanagement_service = ServiceClient(
    "CustomerManagementService",
    version=13,
    authorization_data=authorization_data,
)

get_user_response = customermanagement_service.GetUser(UserId=None)
user = get_user_response.User

你错过authenticationAuthorizationData

于 2021-06-10T09:48:49.850 回答