Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BingAds Client State, oauth_web_auth_code_grant

I would like to get my custom "Reports" data from my BingAds out with the bingads API. I am using the KeywordsAds.py example, which may not be the correct one. However, my problem starts with the authentication, I cannot seem to find all the authentication inputs needed. I am missing examples in like, so I know if I am inserting the right data:

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) To the code above, what authentication do I need to choose for the WebAPI? (2) And for my problem stated, do I need to use a WebAPI, or would a Web platform be more useful?

CLIENT_ID='ClientIdGoesHere'
CLIENT_STATE='ClientStateGoesHere'

3) What is the Client_State? I did google this term, but did not find an explanation. What values could/need to be inserted?

And lastly, I do not find the client_secret and redirection_uri in the example code, but it is stated on the 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

Is this necessary to fill in?

like image 500
ccasimiro9444 Avatar asked Jun 20 '17 05:06

ccasimiro9444


1 Answers

So, I have solved the problem some time back.

The first code block is correct, this is how the examples would look like, just replace the numbers in account_id and customer_id. The developer_token has numbers and letters as displayed in my question. For the authentication, use 'OAuthWebAuthCodeGrant'.

To answer question 1: The WebAPI works, (2) and for CLIENT_ID use the WebAPI's Application ID URI, the part after api://.

Q3: The CLIENT_STATE I left as is, it is not needed.

The last code block int he question is not needed.

If you are a beginner like me and need some help, I made a quick and dirty Python template. It downloads my report to CSV, then I import it to Pandas where I clean the dataset, then I write it again out to CSV, and finally upload it to Google Analytics here

like image 108
ccasimiro9444 Avatar answered Sep 22 '22 08:09

ccasimiro9444