title: Google Ads API: Access with service account
body: <p>I am trying to connect to the google ads api using a service account. For analytics there is a good article named <a href="https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-java" rel="nofollow noreferrer">Hello Analytics API: Java quickstart for service accounts</a> which explains how to set this up. For Google ads I can't find any documentation online.</p>
  <p>So my two questions are:</p>
  <ol>
  <li>Is it possible to access the Google Ads API using a service account?</li>
  <li>If so, is there something like a Hello Ads API: Java quickstart for service accounts page with information on how to connect to the api with a service account?</li>
  </ol>
  <p>UPDATE 2/10</p>
  <p>I succeeded in passing the authentication fase. I do get an error when trying to fetch data from the API.</p>
  <pre><code>curl.exe --request POST &quot;https://googleads.googleapis.com/v5/customers/******/googleAds:searchStream&quot;
  --header &quot;Content-Type: application/json&quot; 
  --header &quot;Authorization: Bearer ******&quot; 
  --header &quot;developer-token: ******&quot; 
  --data &quot;{'query': 'SELECT * FROM campaign WHERE segments.date DURING YESTERDAY'}&quot;
  
  [{
    &quot;error&quot;: {
      &quot;code&quot;: 401,
      &quot;message&quot;: &quot;Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.&quot;,
      &quot;status&quot;: &quot;UNAUTHENTICATED&quot;,
      &quot;details&quot;: [
        {
          &quot;@type&quot;: &quot;type.googleapis.com/google.ads.googleads.v5.errors.GoogleAdsFailure&quot;,
          &quot;errors&quot;: [
            {
              &quot;errorCode&quot;: {
                &quot;authenticationError&quot;: &quot;NOT_ADS_USER&quot;
              },
              &quot;message&quot;: &quot;User in the cookie is not a valid Ads user.&quot;
            }
          ]
        }
      ]
    }
  }
  ]
  </code></pre>
  <p>The google docs say this error is because the account is not associated with an google ads account (<a href="https://developers.google.com/google-ads/api/docs/best-practices/common-errors#not_ads_user" rel="nofollow noreferrer">https://developers.google.com/google-ads/api/docs/best-practices/common-errors#not_ads_user</a>). The request are being processed by the api, I know this because the request are counted in the google ads api console as errors.</p>
  <p>In the Credentials compatible with this API for the google ads Api my service account is listed. I am a little puzzled by the error. The service-account is associated with the google ads account as far as I could tell.</p>