Google Drive API Error Daily Limit for Unauthenticated Use Exceeded

纵然是瞬间 提交于 2019-11-28 12:53:37

The problem was while getting access token. I was not providing correct scopes. When i changed the scope to

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

it worked fine

I was using NodeJS to download a file, but was forgetting to pass the auth.

Initially I was using:

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'
  });
}

afterwards, I added an auth argument to the function, and passed it to the export method as well:

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'
  })
}

I am getting auth by creating an instance of google-auth-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!