超出未经身份验证的使用的Google云端硬盘API错误每日限制

时间:2016-02-17 21:18:33

标签: javascript google-api google-drive-api google-spreadsheet-api google-drive-realtime-api

我在使用Google API时遇到错误。 有权连接Google云端硬盘并添加新工作表并将数据插入其中。

它一直工作到昨天,但是今天我运行应用程序。 我得到错误:

用户在给定令牌并尝试访问DRIVE API以获取所有文件后出现

错误

domain: "usageLimits"
extendedHelp: "https://code.google.com/apis/console"
message: "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
reason: "dailyLimitExceededUnreg"

我没有更改任何设置。 以下API启用了我的应用程序访问令牌。我是否必须添加/启用更多API才能使其正常工作。

enter image description here

2 个答案:

答案 0 :(得分:3)

问题在于获取访问令牌。我没有提供正确的范围。 当我将范围改为

  

https://spreadsheets.google.com/feeds https://docs.google.com/feeds   https://www.googleapis.com/auth/drive.file

它工作正常

答案 1 :(得分:2)

我使用NodeJS下载文件,但忘记通过身份验证。

最初我在使用:

function downloadFiles() {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    fileId: fileId,
    mimeType: 'text/csv'
  });
}

之后,我在函数中添加了auth参数,并将其传递给export方法:

function downloadFiles(auth) {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    auth: auth,
    fileId: fileId,
    mimeType: 'text/csv'
  })
}

我通过创建google-auth-library

的实例获得auth
相关问题