title: Unable to query Google Search Console API using a Service Account
body: <p>I need to retrieve some data from Google Search Console (Webmaster Tools) using a service account.</p>
  
  <p>So far I've been able to retrieve an <code>access_token</code> for the service account which I need to append to the url of the request. The problem is that I can't find a way to do so, this is the code i'm using:</p>
  
  <pre><code>function retrieveSearchesByQuery(token)
      {
          gapi.client.webmasters.searchanalytics.query(
          {
              'access_token': token,
              'siteUrl': 'http://www.WEBSITE.com',
              'fields': 'responseAggregationType,rows',
              'resource': {
                  'startDate': formatDate(cSDate),
                  'endDate': formatDate(cEDate),
                  'dimensions': [
                      'date'
                  ]
              }
          })
          .then(function(response) {
              console.log(response);
          })
          .then(null, function(err) {
              console.log(err);
          });
      }
  </code></pre>
  
  <p>This is the url called by the function:</p>
  
  <pre><code>https://content.googleapis.com/webmasters/v3/sites/http%3A%2F%2Fwww.WEBSITE.com/searchAnalytics/query?fields=responseAggregationType%2Crows&amp;alt=json"
  </code></pre>
  
  <p>Instead it should be something like this:</p>
  
  <pre><code>https://content.googleapis.com/webmasters/v3/sites/http%3A%2F%2Fwww.WEBSITE.com/searchAnalytics/query?fields=responseAggregationType%2Crows&amp;alt=json&amp;access_token=XXX"
  </code></pre>
  
  <p>The <code>gapi.client.webmasters.searchanalytics.query</code> doesn't recognize <code>'access_token'</code> as a valid key thus it doesn't append it to the url and that's why I get a <code>401 Unauthorized</code> as response.</p>
  
  <p>If I use <code>'key'</code> instead of <code>'access_token'</code> the parameter gets appended to the url but <code>'key'</code> is used for <code>OAuth2</code> authentication so the service account token I pass is not valid.</p>
  
  <p>Does anyone have a solution or a workaround for this?</p>