experimental/perf_sheriffing_emailer/api_access.js
function getService(privateKeyDetails) {
  return OAuth2.createService('PerfDash:' + Session.getActiveUser().getEmail())
      // Set the endpoint URL.
      .setTokenUrl('https://accounts.google.com/o/oauth2/token')

      // Set the private key and issuer.
      .setPrivateKey(privateKeyDetails['private_key'])
      .setIssuer(privateKeyDetails['client_email'])

      // Set the property store where authorized tokens should be persisted.
      .setPropertyStore(PropertiesService.getScriptProperties())

      // Set the scope. This must match one of the scopes configured during the
      // setup of domain-wide delegation.
      .setScope('https://www.googleapis.com/auth/userinfo.email');
}
function getService(privateKeyDetails) {
  return OAuth2.createService('PerfDash:' + Session.getActiveUser().getEmail())
      // Set the endpoint URL.
      .setTokenUrl('https://accounts.google.com/o/oauth2/token')

      // Set the private key and issuer.
      .setPrivateKey(privateKeyDetails['private_key'])
      .setIssuer(privateKeyDetails['client_email'])

      // Set the property store where authorized tokens should be persisted.
      .setPropertyStore(PropertiesService.getScriptProperties())

      // Set the scope. This must match one of the scopes configured during the
      // setup of domain-wide delegation.
      .setScope('https://www.googleapis.com/auth/userinfo.email');
}
function getService ( privateKeyDetails ) { return OAuth2 . createService ( 'PerfDash:' + Session . getActiveUser ( ) . getEmail ( ) ) // Set the endpoint URL. . setTokenUrl ( 'https://accounts.google.com/o/oauth2/token' ) // Set the private key and issuer. . setPrivateKey ( privateKeyDetails [ 'private_key' ] ) . setIssuer ( privateKeyDetails [ 'client_email' ] ) // Set the property store where authorized tokens should be persisted. . setPropertyStore ( PropertiesService . getScriptProperties ( ) ) // Set the scope. This must match one of the scopes configured during the // setup of domain-wide delegation. . setScope ( 'https://www.googleapis.com/auth/userinfo.email' ) ; }
Configures the service.
@param {Object} privateKeyDetails Dict with private key and client email.
Configures the service .