lib/googleAuthWrapper.js
function createOauthClient(storagePath, clientSecrets) {
  var secrets = fs.readFileSync(path.join(storagePath,  clientSecrets + '.json'));
  if (secrets === undefined) { 
    throw new Error('failed to read secrets file');
  }
  secrets = JSON.parse(secrets);

  var gAuth = new googleAuth();
  var oauthClient = new gAuth.OAuth2(secrets.installed.client_id,
                                     secrets.installed.client_secret,
                                     secrets.installed.redirect_uris[0]);
  return oauthClient;
}
function createOauthClient(storagePath, clientSecrets) {
  var secrets = fs.readFileSync(path.join(storagePath,  clientSecrets + '.json'));
  if (secrets === undefined) { 
    throw new Error('failed to read secrets file');
  }
  secrets = JSON.parse(secrets);

  var gAuth = new googleAuth();
  var oauthClient = new gAuth.OAuth2(secrets.installed.client_id,
                                     secrets.installed.client_secret,
                                     secrets.installed.redirect_uris[0]);
  return oauthClient;
}
function createOauthClient ( storagePath , clientSecrets ) { var secrets = fs . readFileSync ( path . join ( storagePath , clientSecrets + '.json' ) ) ; if ( secrets === undefined ) { throw new Error ( 'failed to read secrets file' ) ; } secrets = JSON . parse ( secrets ) ; var gAuth = new googleAuth ( ) ; var oauthClient = new gAuth . OAuth2 ( secrets . installed . client_id , secrets . installed . client_secret , secrets . installed . redirect_uris [ 0 ] ) ; return oauthClient ; }
common parts of oauth client creation
common parts of oauth client creation