Google Tasks API Node.js Example Code

Submitted by august on Thu, 08/09/2018 - 23:52
function getAuthClient() {
  var promises = [
    readFile('credentials.json').then(JSON.parse),
    readFile(TOKEN_PATH).then(JSON.parse)
  ];
  return Promise.all(promises).then((results) => {
    var credentials = results[0];
    var token = results[1];
    var client_secret = credentials.installed.client_secret;
    var client_id = credentials.installed.client_id;
    var redirect_uris = credentials.installed.redirect_uris;

    var oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
    oAuth2Client.setCredentials(token);
    return oAuth2Client;
  }, function (err