相关疑难解决方法(0)

Google电子表格API请求的身份验证范围不足

我正在制作一个脚本,使用nodejs上的以下脚本从谷歌电子表格中读取数据:

var url = oauth2Client.generateAuthUrl({
    access_type:     'offline',
    approval_prompt: 'force',
    scope: [
      'https://www.googleapis.com/auth/analytics.readonly',
      'https://www.googleapis.com/auth/drive',
      'https://www.googleapis.com/auth/spreadsheets'
    ]
});
global.googleapis = { expiry_date: 0 };
google.options({ auth: oauth2Client });
var sheets    = google.sheets('v4');
sheets.spreadsheets.get({ spreadsheetId: 'id'}, function(err, data) {
    res.send(err, data);
});
Run Code Online (Sandbox Code Playgroud)

但是在每次获取请求时我都会收到此错误:

Request had insufficient authentication scopes.
Run Code Online (Sandbox Code Playgroud)

我检查了Google开发者控制台以启用Google Drive API并启用了它,所以我真的不知道它会是什么.

google-api node.js google-spreadsheet-api

30
推荐指数
3
解决办法
4万
查看次数