title: Impersonate user with google calendar API oauth2 service account (node.js)
body: <p>I am trying to use a server for server authentication through the google calendar API. In the documentation they mention you can impersonate a user. I have added owner permissions to the account I want to impersonate and made sure the domain-wide delegation is enabled. From what I have read, the 'user@example' should specify the impersonator, but it does not work. I have all the functions of creating events etc working, but I can't get it to be from an email other than the randomly generated google one.</p>
  <p>Here's my code:</p>
  <pre><code>var google = require('googleapis');
  var calendar = google.calendar('v3');
  var scopes = ['https://www.googleapis.com/auth/calendar'];
  var key = require ('./xxx.json'); // private json
  console.log(&quot;Calendar Service connected&quot;);
  var jwtClient = new google.auth.JWT(
    key.client_email, 
    null, 
    key.private_key, 
    scopes,
    'user@example.com'
  );
  jwtClient.authorize(function(err, token) {
    if(err) { 
      //console.log(err);
    }
    console.log('token',token);
    //listCalendars(jwtClient);
  });
  
  module.exports = {};
  </code></pre>