title: How to get data from Microsoft Bing Ads API
body: <p>I'm trying to get Bing ads spends from my firm. According to the Microsoft documentation, I understood that it's mandatory to use Microsoft Azure portal, get <code>developer_token</code>, <code>client_id</code>, <code>tenant_id</code>, <code>client_secret</code>, and access/refresh token to download the <code>csv</code> files with the data I want.</p>
  <p>So, this is what I did:</p>
  <ol>
  <li><p>I've received an invitation from my firm to Microsoft advertising onto this email adress:
  <strong>abc@myfirm.fr</strong>, and I've generated my developer token.</p>
  </li>
  <li><p><strong>With this email address</strong>, I've created a web application onto Microsoft Azure portal, which allow all king of users. Getting <code>client_id</code>, <code>tenant_id</code>, and generated a <code>client_secret</code>.</p>
  </li>
  <li><p>The redirect URL that I have chosen is <strong>http://localhost</strong> (according to the documentation but not sure this is the good URL to choose).</p>
  </li>
  <li><p>With Postman, I have tried with this endpoint:
  <strong><a href="https://login.microsoftonline.com/common/oauth2/v2.0/authorize" rel="nofollow noreferrer">https://login.microsoftonline.com/common/oauth2/v2.0/authorize</a></strong>
  and the params (previously obtained) needed for the OAuth 2.0 authentication to get my access token. Without success.</p>
  </li>
  </ol>
  <p>The issue is here.</p>
  <p>When I request the access token, a new browser window opens, and asks for an email address on which to authenticate. I'm using my email address <strong>abc@myfirm.fr</strong> and I received <code>authentication completed</code> onto Postman but into the response body I have <code>access_token: invalid</code>.</p>
  <p>The role of my account is super admin.</p>
  <p>So I'm trying to authenticate with a professional Microsoft Azure Account and this time I received into the browser <code>Invalid redirect url</code>.</p>
  <p>I have also tried to start all over again with different email address, like my personal email address, or with the email address of the creator of the Microsoft Advertising account, and I get the error <code>contact your system Admin</code> into the browser.</p>
  <p>I have also tried with the Python SDK project given in the documentation, with the error message.</p>
  <p>I must have forgotten or misunderstood something.</p>
  <p>Should we use the same email address (or same account) on Microsoft Advertising, on Microsoft Azure, and when obtaining the access token?</p>
  <p>Do you have to pay and take an Azure subscription? (Already done but without success)</p>
  <p>Thanks in advance, sorry for my English.</p>
  <p>EDIT:</p>
  <p>Thank for ypur reply. The full request is: <a href="https://login.microsoftonline.com/common/oauth2/v2.0/authorize" rel="nofollow noreferrer">https://login.microsoftonline.com/common/oauth2/v2.0/authorize</a> with the following params:</p>
  <p>-type: OAuth 2.0</p>
  <p>-Header Prefix: Bearer</p>
  <p>-Grant Type: Authorization Code</p>
  <p>-Callback URL: https://localhost</p>
  <p>-Auth URL: <a href="https://login.microsoftonline.com/%7Bmy-tenant_id%7D/oauth2/v2.0/authorize" rel="nofollow noreferrer">https://login.microsoftonline.com/{my-tenant_id}/oauth2/v2.0/authorize</a></p>
  <p>-Access Token URL: <a href="https://login.microsoftonline.com/%7Bmy-tenant_id%7D/oauth2/v2.0/token" rel="nofollow noreferrer">https://login.microsoftonline.com/{my-tenant_id}/oauth2/v2.0/token</a></p>
  <p>-my client id</p>
  <p>-my client secret</p>
  <p>-scope: <a href="https://ads.microsoft.com/ads.manage" rel="nofollow noreferrer">https://ads.microsoft.com/ads.manage</a> OR also testing with <a href="https://graph.microsoft.com/User.Read" rel="nofollow noreferrer">https://graph.microsoft.com/User.Read</a></p>
  <p>-State: None</p>
  <p>-Client authentication: send client credentials in body</p>
  <p>Give me an access_token but when I click on use token and send the request, I'm not getting an refresh token</p>