functions/calendar.js
/**
 * Create an OAuth2 client with the given credentials, and then execute the
 * given callback function.
 *
 * @param {Object} credentials The authorization client credentials.
 * @param {function} callback The callback to call with the authorized client.
 */
Create an OAuth2 client with the given credentials, and then execute the
given callback function.

@param {Object} credentials The authorization client credentials.
@param {function} callback The callback to call with the authorized client.
Create an OAuth2 client with the given credentials and then execute the given callback function . @param { Object } credentials The authorization client credentials . @param { function } callback The callback to call with the authorized client .
function authorize(credentials, callback) {
  console.log(credentials);
  var clientSecret = credentials.web.client_secret;
  var clientId = credentials.web.client_id;
  var redirectUrl = credentials.web.redirect_uris[0];
  console.log(redirectUrl);
  var auth = new googleAuth();
  var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl);
  fs.readFile(TOKEN_PATH, function(err, token) {
    if (err) {
      getNewToken(oauth2Client, callback);
    } else {
      oauth2Client.credentials = JSON.parse(token);
      return callback(oauth2Client);
    }
  });
}
function authorize ( credentials , callback ) { console . log ( credentials ) ; var clientSecret = credentials . web . client_secret ; var clientId = credentials . web . client_id ; var redirectUrl = credentials . web . redirect_uris [ 0 ] ; console . log ( redirectUrl ) ; var auth = new googleAuth ( ) ; var oauth2Client = new auth . OAuth2 ( clientId , clientSecret , redirectUrl ) ; fs . readFile ( TOKEN_PATH , function ( err , token ) { if ( err ) { getNewToken ( oauth2Client , callback ) ; } else { oauth2Client . credentials = JSON . parse ( token ) ; return callback ( oauth2Client ) ; } } ) ; }
Create an OAuth2 client with the given credentials, and then execute the
 given callback function.
Create an OAuth2 client with the given credentials and then execute the given callback function .
// Check if we have previously stored a token.