code: function XOAuth2Generator(options) {
      Stream.call(this);
      this.options = options || {};
  
      if (options && options.service) {
          if (!options.scope || !options.privateKey || !options.user) {
              throw new Error('Options "scope", "privateKey" and "user" are required for service account!');
          }
  
          var serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
          this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
      }
  
      this.options.accessUrl = this.options.accessUrl || 'https://accounts.google.com/o/oauth2/token';
      this.options.customHeaders = this.options.customHeaders || {};
      this.options.customParams = this.options.customParams || {};
  
      this.token = this.options.accessToken && this.buildXOAuth2Token(this.options.accessToken) || false;
      this.accessToken = this.token && this.options.accessToken || false;
  
      var timeout = Math.max(Number(this.options.timeout) || 0, 0);
      this.timeout = timeout && Date.now() + timeout * 1000 || 0;
  }
docs: XOAUTH2 access_token generator for Gmail.
  Create client ID for web applications in Google API console to use it.
  See Offline Access for receiving the needed refreshToken for an user
  https://developers.google.com/accounts/docs/OAuth2WebServer#offline
  
  @constructor
  @param {Object} options Client information for token generation
  @param {String} options.user         (Required) User e-mail address
  @param {String} options.clientId     (Required) Client ID value
  @param {String} options.clientSecret (Required) Client secret value
  @param {String} options.refreshToken (Required) Refresh token for an user
  @param {String} options.accessUrl    (Optional) Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token'
  @param {String} options.accessToken  (Optional) An existing valid accessToken
  @param {int}    options.timeout      (Optional) TTL in seconds