Node.js 错误:请求的身份验证作用域不足。我只想远程运行一个函数

Node.js 错误:请求的身份验证作用域不足。我只想远程运行一个函数,node.js,google-apps-script,oauth-2.0,google-api,Node.js,Google Apps Script,Oauth 2.0,Google Api,我在这方面已经做了几个小时了,我感到非常沮丧。我在GoogleApps脚本中有一个脚本,它包含8个参数,并使用它们相应地修改GoogleSheet 我已经做到了这一点,但我只得到了“错误:请求的身份验证作用域不足” const fs = require('fs'); const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete

我在这方面已经做了几个小时了,我感到非常沮丧。我在GoogleApps脚本中有一个脚本,它包含8个参数,并使用它们相应地修改GoogleSheet

我已经做到了这一点,但我只得到了“错误:请求的身份验证作用域不足”

const fs = require('fs');
const readline = require('readline');
const {google} = require('googleapis');

// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/script.projects'];
const TOKEN_PATH = 'token.json';

// Load client secrets from a local file.
fs.readFile('credentials.json', (err, content) => {
  if (err) return console.log('Error loading client secret file:', err);
  // Authorize a client with credentials, then call the Google Apps Script API.
  authorize(JSON.parse(content), callAppsScript);
});

/**
 * 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) {
  const {client_secret, client_id, redirect_uris} = credentials.installed;
  const oAuth2Client = new google.auth.OAuth2(
      client_id, client_secret, redirect_uris[0]);

  // Check if we have previously stored a token.
  fs.readFile(TOKEN_PATH, (err, token) => {
    if (err) return getAccessToken(oAuth2Client, callback);
    oAuth2Client.setCredentials(JSON.parse(token));
    callback(oAuth2Client);
  });
}

/**
 * Get and store new token after prompting for user authorization, and then
 * execute the given callback with the authorized OAuth2 client.
 * @param {google.auth.OAuth2} oAuth2Client The OAuth2 client to get token for.
 * @param {getEventsCallback} callback The callback for the authorized client.
 */
function getAccessToken(oAuth2Client, callback) {
  const authUrl = oAuth2Client.generateAuthUrl({
    access_type: 'offline',
    scope: SCOPES,
  });
  console.log('Authorize this app by visiting this url:', authUrl);
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  rl.question('Enter the code from that page here: ', (code) => {
    rl.close();
    oAuth2Client.getToken(code, (err, token) => {
      if (err) return console.error('Error retrieving access token', err);
      oAuth2Client.setCredentials(token);
      // Store the token to disk for later program executions
      fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
        if (err) console.error(err);
        console.log('Token stored to', TOKEN_PATH);
      });
      callback(oAuth2Client);
    });
  });
}

/**
 * Creates a new script project, upload a file, and log the script's URL.
 * @param {google.auth.OAuth2} auth An authorized OAuth2 client.
 */
/**
 * Call an Apps Script function to list the folders in the user's root
 * Drive folder.
 *
 * @param {google.auth.OAuth2} auth An authorized OAuth2 client.
 */
function callAppsScript(auth) { // eslint-disable-line no-unused-vars
    const scriptId = 'MqXrmZ5VhTSo4YuWEH6-b4UfoO49Cn6ao';
    const script = google.script('v1');

    // Make the API request. The request object is included here as 'resource'.
    script.scripts.run({
      auth: auth,
      resource: {
        function: 'automateSheet',
        parameters: [
            322,
            6549.51,
            4388,
            282.98,
            454.13,
            168,
            302
        ]
      },
      scriptId: scriptId,
    }, function(err, resp) {
      if (err) {
        // The API encountered a problem before the script started executing.
        console.log('The API returned an error: ' + err);
        return;
      }
      if (resp.error) {
        // The API executed, but the script returned an error.

        // Extract the first (and only) set of error details. The values of this
        // object are the script's 'errorMessage' and 'errorType', and an array
        // of stack trace elements.
        const error = resp.error.details[0];
        console.log('Script error message: ' + error.errorMessage);
        console.log('Script error stacktrace:');

        if (error.scriptStackTraceElements) {
          // There may not be a stacktrace if the script didn't start executing.
          for (let i = 0; i < error.scriptStackTraceElements.length; i++) {
            const trace = error.scriptStackTraceElements[i];
            console.log('\t%s: %s', trace.function, trace.lineNumber);
          }
        }
      } else {
        // The structure of the result will depend upon what the Apps Script
        // function returns. Here, the function returns an Apps Script Object
        // with String keys and values, and so the result is treated as a
        // Node.js object (folderSet).
        console.log("Success");
      }
    });
  }

这个确认和修改怎么样

确认要点:
  • 请在脚本编辑器中确认Google Apps脚本使用的范围。
    • 文件->项目属性->范围
    • 复制它们
    • 这些作用域用于运行Google Apps脚本。如果客户端脚本中未包含脚本编辑器的作用域(在您的示例中为node.js脚本),则
      请求的错误没有足够的验证作用域。
      发生
  • 请再次确认是否在API控制台启用了应用程序脚本API
修改点:
  • 请将上面复制的作用域包含到node.js端的脚本中
  • 关于
    资源
    参数
    ,在您的情况下,Google Apps脚本的函数需要有7个参数,如
    函数自动机Sheet(a、b、c、d、e、f、g){}
    。如果您想将then用作数组,请修改为
    参数:[[3226549.514388282.98454.13168302]]
    。通过此操作,您可以设置函数,如
    函数automateSheet(a){}
  • 如何将
    devMode:true
    属性添加到资源中?这样,当您修改Google Apps脚本时,node.js端的脚本可以使用最新的Google Apps脚本。如果
    devMode
    false
    ,当您修改Google Apps脚本时,需要更新脚本的版本
当上述修改反映到您的脚本中时,请按以下方式进行修改

修改第1部分: 发件人: 致: 至少从你的问题来看,
https://www.googleapis.com/auth/spreadsheets
可能包括在内。如果在您的Google Apps脚本中使用了其他作用域,也请添加它们

修改第2部分: 发件人: 致: 修改第3部分: 发件人: 致: 通过此修改,您可以在运行Google Apps脚本时看到响应。关于此,请决定是否修改此

注:
  • 如果在您的Google Apps脚本中,您正在使用类似
    函数automateSheet(a、b、c、d、e、f、g){}
    ,请从
    参数修改:[[3226549.514388282.98454.13168302]
    参数:[3226549.514388282.98454.13168302]
  • 当在脚本编辑器中看到“文件->项目属性->信息”时,
    项目密钥
    显示为
    已弃用
    项目密钥
    与“部署为API可执行文件”中显示的“当前API ID”相同“。在当前阶段,可以使用
    项目密钥
    。但考虑到未来的更新,使用
    scriptid
    可能会更好。这是我的考虑
参考:
补充: 如果您希望通过分离应用程序脚本API中的错误消息和结果来显示,那么此修改如何

发件人: 致: 或

致:
运行脚本需要不同的权限,具体取决于它的功能。如果您的节点代码读取您的Gmail,则需要Gmail作用域来获取节点的OAuth凭据。如果你的应用程序脚本代码读取Gmail,那么。。。令人惊讶的是,它需要Gmail示波器。您可以查看相关文档中应用程序脚本代码所需的所有作用域。此脚本仅更新google工作表。我已经尝试将所有相关的作用域添加到我的请求和脚本的清单文件中。您是否从编辑器中运行应用程序脚本?是的,它工作得非常好。我正在尝试更新我的凭据。我有客户id和客户机密。从那里我该去哪里?我也可以通过ajax调用运行脚本吗?谢谢你的回答,我的问题实际上是一个简单的oauth问题,我已经解决了。我使用了错误项目的凭证,真不敢相信我在上面浪费了多少时间。然而,当我在本地运行脚本时,它似乎在中途停止。我将“Success”更改为resp.data,结果是
{done:true,error:{code:3,message:'TypeError',details:[[Object]]}}}
当我通过脚本编辑器运行脚本时,脚本工作正常。关于如何解决这个问题有什么建议吗?@SethMcGuire我很高兴你的问题解决了。但我没注意到你问题的原因。我真的很抱歉我的技术很差。然后,对于你的新问题,我更新了我的答案。你能确认一下吗?别抱歉,这是一个艰难的发现。感谢更新的答案,错误信息现在更清楚了。我收到
errorMessage:'无法从未定义中读取属性“2”。
它所在的行来自我的for循环:
var values=SpreadsheetApp.getActiveSheet().getDataRange().getValues()
for(n=3;n<10;n++){btcSevenQuantity+=values[n][2];
我在脚本编辑器中运行它时没有收到此错误。非常奇怪
function automateSheet(btcQuantity, btcCost, btcCount, bchQuantity, bchCost, bchCount, merchantCount){
  if(!btcQuantity || !btcCost || !btcCount || !bchQuantity || !bchCost || !bchCount || !merchantCount){
   //Send back "Wtf are you doing?"
  } else {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheets()[1];
  const charts = ss.getSheets()[0];


  sheet.insertRowBefore(4);
  //yellow
  sheet.getRange("A4").setValue(new Date());
  sheet.getRange("C4").setValue(btcQuantity);
  sheet.getRange("D4").setValue(btcCost);
  sheet.getRange("E4").setValue(btcCount);
  sheet.getRange("G4").setValue(bchQuantity);
  sheet.getRange("H4").setValue(bchCost);
  sheet.getRange("I4").setValue(bchCount);
  sheet.getRange("K4").setValue(merchantCount);

  //BTC Stats
  var btcValue = btcQuantity * btcCost;
  var bchValue = bchQuantity * bchCost;
  var totalValue = btcValue + bchValue;
  var btcValPercent = btcValue / totalValue;
  var bchValPercent = bchValue / totalValue;
  var totalCount = btcCount + bchCount;
  var btcCountPercent = btcCount / totalCount;
  var bchCountPercent = bchCount / totalCount;

  sheet.getRange("M4").setValue(btcValue);
  sheet.getRange("N4").setValue(btcValue / btcCount);
  sheet.getRange("O4").setValue(btcValPercent);
  sheet.getRange("P4").setValue(btcCountPercent);

  //BCH Stats
  sheet.getRange("R4").setValue(bchValue);
  sheet.getRange("S4").setValue(bchValue / bchCount);
  sheet.getRange("T4").setValue(bchValPercent);
  sheet.getRange("U4").setValue(bchCountPercent);

  //Combined Stats
  var combinedCount = btcCount + bchCount;
  var combinedValue = btcValue + bchValue;
  var combinedAvg = combinedValue / combinedCount;
  sheet.getRange("W4").setValue(combinedCount);
  sheet.getRange("X4").setValue(combinedValue);
  sheet.getRange("Y4").setValue(combinedAvg);

  //BTC and BCH Stats (7DMA)
  var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues();

  var btcSevenQuantity = 0;
  var btcSevenCount = 0;
  var btcSevenValue = 0;

  var bchSevenQuantity = 0;
  var bchSevenCount = 0;
  var bchSevenValue = 0;
  var merchantCount = 0;

  for(n = 3; n < 10; n++){
    btcSevenQuantity += values[n][2];
    btcSevenCount += values[n][4];
    btcSevenValue += values[n][12];

    bchSevenQuantity += values[n][6];
    bchSevenCount += values[n][8];
    bchSevenValue += values[n][17];

    merchantCount += values[n][10];
  }

  var btcSevenQuantityAvg = btcSevenQuantity / 7;
  var btcSevenCountAvg = btcSevenCount / 7;
  var btcSevenValueAvg = btcSevenValue / 7;
  var btcSevenAvgVal = btcSevenValueAvg / btcSevenCountAvg;

  var bchSevenQuantityAvg = bchSevenQuantity / 7;
  var bchSevenCountAvg = bchSevenCount / 7;
  var bchSevenValueAvg = bchSevenValue / 7;
  var bchSevenAvgVal = bchSevenValueAvg / bchSevenCountAvg;

  var combinedSevenValueTotal = btcSevenValue + bchSevenValue;
  var combinedSevenCountTotal = btcSevenCount + bchSevenCount;

  var btcSevenValPer = btcSevenValue / combinedSevenValueTotal;
  var bchSevenValPer = bchSevenValue / combinedSevenValueTotal
  var btcSevenCountPer = btcSevenCount / combinedSevenCountTotal;
  var bchSevenCountPer = bchSevenCount / combinedSevenCountTotal;

  var combinedSevenCountAvg = combinedSevenCountTotal / 7;
  var combinedSevenValueAvg = combinedSevenValueTotal / 7;
  var combinedSevenAvgVal = combinedSevenValueTotal / combinedSevenCountTotal;

  var sevenMerchantAvg = merchantCount / 7;

  sheet.getRange("AA4").setValue(btcSevenQuantityAvg);
  sheet.getRange("AB4").setValue(btcSevenCountAvg);
  sheet.getRange("AC4").setValue(btcSevenValueAvg);
  sheet.getRange("AD4").setValue(btcSevenAvgVal);
  sheet.getRange("AE4").setValue(btcSevenValPer);
  sheet.getRange("AF4").setValue(btcSevenCountPer);

  sheet.getRange("AH4").setValue(bchSevenQuantityAvg);
  sheet.getRange("AI4").setValue(bchSevenCountAvg);
  sheet.getRange("AJ4").setValue(bchSevenValueAvg);
  sheet.getRange("AK4").setValue(bchSevenAvgVal);
  sheet.getRange("AL4").setValue(bchSevenValPer);
  sheet.getRange("AM4").setValue(bchSevenCountPer);

  sheet.getRange("AO4").setValue(combinedSevenCountAvg);
  sheet.getRange("AP4").setValue(combinedSevenValueAvg);
  sheet.getRange("AQ4").setValue(combinedSevenAvgVal);
  sheet.getRange("AR4").setValue(sevenMerchantAvg);

  var sevenCount = charts.getRange("G3").getValue();
  var sevenValue = charts.getRange("G4").getValue();
  var sevenAvgVal = charts.getRange("G5").getValue();
  var sevenMerchants = charts.getRange("G6").getValue();

  if(sevenCount > combinedSevenCountAvg){
    charts.getRange("G3").setBackgroundRGB(244, 199, 195);
  } else if(sevenCount < combinedSevenCountAvg){
    charts.getRange("G3").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("G3").setBackground("white");
  }

    if(sevenValue > combinedSevenValueAvg){
    charts.getRange("G4").setBackgroundRGB(244, 199, 195);
  } else if(sevenCount < combinedSevenCountAvg){
    charts.getRange("G4").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("G4").setBackground("white");
  }

    if(sevenAvgVal > combinedSevenAvgVal){
    charts.getRange("G5").setBackgroundRGB(244, 199, 195);
  } else if(sevenAvgVal < combinedSevenAvgVal){
    charts.getRange("G5").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("G5").setBackground("white");
  }

    if(sevenMerchants > sevenMerchantAvg){
    charts.getRange("G6").setBackgroundRGB(244, 199, 195);
  } else if(sevenMerchants < sevenMerchantAvg){
    charts.getRange("G6").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("G6").setBackground("white");
  }

  charts.getRange("G3").setValue(Math.round(combinedSevenCountAvg));
  charts.getRange("G4").setValue(parseFloat(combinedSevenValueAvg).toFixed(2));
  charts.getRange("G5").setValue(parseFloat(combinedSevenAvgVal).toFixed(2));
  charts.getRange("G6").setValue(Math.round(sevenMerchantAvg));


  //BTC and BCH Stats (30DMA)

  var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues();

  var btcThirtyQuantity = 0;
  var btcThirtyCount = 0;
  var btcThirtyValue = 0;

  var bchThirtyQuantity = 0;
  var bchThirtyCount = 0;
  var bchThirtyValue = 0;
  var merchantCount = 0;

  for(n = 3; n < 33; n++){
    btcThirtyQuantity += values[n][2];
    btcThirtyCount += values[n][4];
    btcThirtyValue += values[n][12];

    bchThirtyQuantity += values[n][6];
    bchThirtyCount += values[n][8];
    bchThirtyValue += values[n][17];

    merchantCount += values[n][10];
  }

  var btcThirtyQuantityAvg = btcThirtyQuantity / 30;
  var btcThirtyCountAvg = btcThirtyCount / 30;
  var btcThirtyValueAvg = btcThirtyValue / 30;
  var btcThirtyAvgVal = btcThirtyValueAvg / btcThirtyCountAvg;

  var bchThirtyQuantityAvg = bchThirtyQuantity / 30;
  var bchThirtyCountAvg = bchThirtyCount / 30;
  var bchThirtyValueAvg = bchThirtyValue / 30;
  var bchThirtyAvgVal = bchThirtyValueAvg / bchThirtyCountAvg;

  var combinedValueTotal = btcThirtyValue + bchThirtyValue;
  var combinedCountTotal = btcThirtyCount + bchThirtyCount;

  var btcThirtyValPer = btcThirtyValue / combinedValueTotal;
  var bchThirtyValPer = bchThirtyValue / combinedValueTotal
  var btcThirtyCountPer = btcThirtyCount / combinedCountTotal;
  var bchThirtyCountPer = bchThirtyCount / combinedCountTotal;

  var combinedCountAvg = combinedCountTotal / 30;
  var combinedValueAvg = combinedValueTotal / 30;
  var combinedAvgVal = combinedValueTotal / combinedCountTotal;

  var thirtyMerchantAvg = merchantCount / 30;

  sheet.getRange("AT4").setValue(btcThirtyQuantityAvg);
  sheet.getRange("AU4").setValue(btcThirtyCountAvg);
  sheet.getRange("AV4").setValue(btcThirtyValueAvg);
  sheet.getRange("AW4").setValue(btcThirtyAvgVal);
  sheet.getRange("AX4").setValue(btcThirtyValPer);
  sheet.getRange("AY4").setValue(btcThirtyCountPer);

  sheet.getRange("BA4").setValue(bchThirtyQuantityAvg);
  sheet.getRange("BB4").setValue(bchThirtyCountAvg);
  sheet.getRange("BC4").setValue(bchThirtyValueAvg);
  sheet.getRange("BD4").setValue(bchThirtyAvgVal);
  sheet.getRange("BE4").setValue(bchThirtyValPer);
  sheet.getRange("BF4").setValue(bchThirtyCountPer);

  sheet.getRange("BH4").setValue(combinedCountAvg);
  sheet.getRange("BI4").setValue(combinedValueAvg);
  sheet.getRange("BJ4").setValue(combinedAvgVal);
  sheet.getRange("BK4").setValue(thirtyMerchantAvg);

  var thirtyCount = charts.getRange("H3").getValue();
  var thirtyValue = charts.getRange("H4").getValue();
  var thirtyAvgVal = charts.getRange("H5").getValue();
  var thirtyMerchants = charts.getRange("H6").getValue();

  if(thirtyCount > combinedCountAvg){
    charts.getRange("H3").setBackgroundRGB(244, 199, 195);
  } else if(thirtyCount < combinedCountAvg){
    charts.getRange("H3").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("H3").setBackground("white");
  }

    if(thirtyValue > combinedValueAvg){
    charts.getRange("H4").setBackgroundRGB(244, 199, 195);
  } else if(thirtyCount < combinedCountAvg){
    charts.getRange("H4").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("H4").setBackground("white");
  }

    if(thirtyAvgVal > combinedAvgVal){
    charts.getRange("H5").setBackgroundRGB(244, 199, 195);
  } else if(thirtyAvgVal < combinedAvgVal){
    charts.getRange("H5").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("H5").setBackground("white");
  }

    if(thirtyMerchants > thirtyMerchantAvg){
    charts.getRange("H6").setBackgroundRGB(244, 199, 195);
  } else if(thirtyMerchants < thirtyMerchantAvg){
    charts.getRange("H6").setBackgroundRGB(183, 225, 205);
  } else {
    charts.getRange("H6").setBackground("white");
  }

  charts.getRange("H3").setValue(Math.round(combinedCountAvg));
  charts.getRange("H4").setValue(parseFloat(combinedValueAvg).toFixed(2));
  charts.getRange("H5").setValue(parseFloat(combinedAvgVal).toFixed(2));
  charts.getRange("H6").setValue(Math.round(thirtyMerchantAvg));




  //Charts
  var dailyVolume = charts.getCharts()[0];
  var range = charts.getRange("'Raw Data'!A4:A368");
  var range2 = charts.getRange("'Raw Data'!BI4:BI368");
  var range3 = charts.getRange("'Raw Data'!AV4:AV368");
  var range4 = charts.getRange("'Raw Data'!BC4:BC1761");
  var chart = dailyVolume.modify()
    .clearRanges()
    .addRange(range)
    .addRange(range2)
    .addRange(range3)
    .addRange(range4)
    .build();
  charts.updateChart(chart);

  var avgOrderValue = charts.getCharts()[1];
  var range = charts.getRange("'Raw Data'!A4:A368");
  var range2 = charts.getRange("'Raw Data'!BJ4:BJ368");
  var range3 = charts.getRange("'Raw Data'!AW4:AW368");
  var range4 = charts.getRange("'Raw Data'!BD4:BD1761");
  var chart = avgOrderValue.modify()
    .clearRanges()
    .addRange(range)
    .addRange(range2)
    .addRange(range3)
    .addRange(range4)
    .build();
  charts.updateChart(chart);

  var bchMarketShare = charts.getCharts()[2];
  var range = charts.getRange("'Raw Data'!A4:A115");
  var range2 = charts.getRange("'Raw Data'!AL4:AL1761");
  var range3 = charts.getRange("'Raw Data'!AM4:AM1761");
  var range4 = charts.getRange("'Raw Data'!BE4:BE1761");
  var range5 = charts.getRange("'Raw Data'!BF4:BF1761");
  var chart = bchMarketShare.modify()
    .clearRanges()
    .addRange(range)
    .addRange(range2)
    .addRange(range3)
    .addRange(range4)
    .addRange(range5)
    .build();
  charts.updateChart(chart);

  var dailyCount = charts.getCharts()[3];
  var range = charts.getRange("'Raw Data'!A4:A368");
  var range2 = charts.getRange("'Raw Data'!BH4:BH368");
  var range3 = charts.getRange("'Raw Data'!AU4:AU368");
  var range4 = charts.getRange("'Raw Data'!BB4:BB1761");
  var chart = dailyCount.modify()
    .clearRanges()
    .addRange(range)
    .addRange(range2)
    .addRange(range3)
    .addRange(range4)
    .build();
  charts.updateChart(chart);

  var dailyMerchants = charts.getCharts()[4];
  var range = charts.getRange("'Raw Data'!A4:A368");
  var range2 = charts.getRange("'Raw Data'!BK4:BK368");
  var chart = dailyMerchants.modify()
    .clearRanges()
    .addRange(range)
    .addRange(range2)
    .build();
  charts.updateChart(chart);
  }
}



automateSheet(322, 6549.51, 4388, 282.98, 454.13, 168, 302);
      function callScriptFunction(auth) {
        var scriptId = "M1bIaRPIiFDfQlsKPJEAKTrwdKP7CN6eO";
        var script = google.script('v1');

        script.scripts.run ({
            auth: auth,
            resource: {
                function: 'automateSheet'
            },
            scriptId: scriptId,
        }, function(err, resp){
            if(err){
                console.log(err);
            }
            else {
                var r = resp.data;
if ("error" in r) {
    console.log("Error: %o", r.error);
} else {
    console.log("Result: %o", r.response.result);
}
            }
        });
      }
const SCOPES = ['https://www.googleapis.com/auth/script.projects'];
const SCOPES = ['https://www.googleapis.com/auth/script.projects', 'https://www.googleapis.com/auth/spreadsheets'];
script.scripts.run({
  auth: auth,
  resource: {
    function: 'automateSheet',
    parameters: [
        322,
        6549.51,
        4388,
        282.98,
        454.13,
        168,
        302
    ]
  },
  scriptId: scriptId,
}, function(err, resp) {
script.scripts.run({
  auth: auth,
  resource: {
    function: 'automateSheet',
    parameters: [[ // Modified
        322,
        6549.51,
        4388,
        282.98,
        454.13,
        168,
        302,
    ]],
  },
  scriptId: scriptId,
  devMode: true, // Added
}, function(err, resp) {
console.log("Success");
console.log(resp.data);
console.log(resp.data);
var r = resp.data;
if ("error" in r) {
    console.log("Error: %o", r.error);
} else {
    console.log("Result: %o", r.response.result);
}
console.log(JSON.stringify(resp.data))