Reputation: 389
I am struggling with bings api python to get all campaign.
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)
it gives me error: suds.WebFault: Server raised fault: 'Invalid client data. Check the SOAP fault details for more information. TrackingId: 1ee709e5-b0d5-4b82-a19e-65001a80789e.
Please help me to get rid out this.
Upvotes: 2
Views: 2325
Reputation: 313
Here is a minimal example:
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
You are missing authentication
in AuthorizationData
Upvotes: 4