Google电子表格api请求的认证范围不足 [英] Google spreadsheet api Request had insufficient authentication scopes

查看:132
本文介绍了Google电子表格api请求的认证范围不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm making an script to read data from google spreadsheet using the following script on 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);
});

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

But on every get request i'm getting this error:

Request had insufficient authentication scopes.

我检查了Google开发者控制台以启用Google Drive API并启用了它,所以我不知道它可能是什么。

I checked the Google developers console to enable the Google Drive API and it's enabled, so I dont really know what could it be.

推荐答案

范围看起来很不错,也许您应该尝试删除以前存储在 /Users/yourUserName/.credentials/sheets.googleapis.com-projectName/ * ,然后再次执行该应用程序以获取新凭据。

The scopes look good, maybe you should try to remove the credentials stored previously in /Users/yourUserName/.credentials/sheets.googleapis.com-projectName/*, and then execute the application again to get new credentials.

这篇关于Google电子表格api请求的认证范围不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆