title: Google API auth via service key succeeds, but still gets "401 Login Required" on subsequent requests
body: <p>I am using the service key method to authenticate with googleapis in node.js. I can authenticate successfully, but when I try to make a request after that I get a "401 Login Required" error.</p>
  
  <p>Here is the authentication code:</p>
  
  <pre><code>const google = require('googleapis').google;
  const privateKey = require('./private_key.json');
  
  const jwtClient = new google.auth.JWT(
      privateKey.client_email,
      null,
      privateKey.private_key,
      [
          'https://www.googleapis.com/auth/analytics.readonly'
      ]
  );
  
  jwtClient.authorize((err, tokens) =&gt; {
      if(err) {
          console.log(err);
      }
      else {
          console.log('Google Authenticated');
      }
  });
  </code></pre>
  
  <p>In the above code, the "Google Authenticated" text is shown successfully, indicating authentication should have succeeded.</p>
  
  <p>But when I try to use the API after that, I get a 401 error back from this:</p>
  
  <pre><code>google.analytics('v3').data.ga.get({
      auth: jwtClient,
      ids: 'ga:xxxxxxxx',
      'start-date': '30daysAgo',
      'end-date': 'today',
      'metrics': 'ga:pageviews'
  }).then((err, result) =&gt; {
      // error object here contains a 401
      if(err) return console.log(err);
      console.log(result);
  });
  </code></pre>