Although there’s plenty of documentation by Microsoft on how to use their Bing Ads API the documentation on how to initially connect to it seems a bit fragmented so this is an attempt to summarize all the steps required to grant a console application access to the API.

Most of these details come from these articles.

In order to connect to the API you need the following pieces of information.

  • Developer Token
  • Customer ID
  • Account ID
  • Client ID
  • Refresh Token
Developer Token

This can be found here.

Customer ID & Account ID

These can be found here, they’re present in the URL as the customer and account route values.<CUSTOMERID>&aid=<ACCOUNTID>#/customer/<CUSTOMERID>/account/<ACCOUNTID>/campaign
Client ID & Refresh Token

In my case I wanted a console application to be able to access the Bing Ads API and get details of ongoing campaigns without any user interaction so I wanted to get the initial refresh token manually and then allow the application to request a new one when required.

To allow the console application to authenticate it needs to be registered in the application portal as specified here. This application should be created as a “Native Application”, the Application ID for this application is the Client ID that is used to authenticate with OAuth and generate a Refresh token.

You should then use Client ID from the created application in the below URL, the client state code can be whatever you like.<CLIENTID>&scope=bingads.manage&response_type=token&redirect_uri=<CLIENTSTATECODE>

This URL will take you to a login screen where you should login with the same account that is used to access the Bing Ads account, it will then ask for permission to access Bing Ads on your behalf.

Once accepted it will redirect to a blank webpage from which you can extract the access code from the URL.<CODE>&state=<CLIENTSTATECODE>&lc=1033

The code and Client ID should then be posted to the OAuth login service to get the refresh token.

Accept: application/json
Content-Type: application/x-www-form-urlencoded
Content-Length: ContentLengthGoesHere


The returned refresh token can then be used in conjunction with your developer token and clientId in your console application, code for a sample application can be found here.

I’ve created a sample web application for getting these refresh tokens here.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *