javascript - 谷歌驱动器 API 超出用户速率限制

标签 javascript google-api google-drive-api

我正在 Google Drive API 之上构建一个网络应用程序。基本上,Web 应用程序显示照片和视频。媒体存储在 Google Drive 文件夹中:一旦通过身份验证,应用程序就会向 Google Drive API 发出请求以获取媒体的 URL 并显示每个 URL。目前,我只有 16 张图像要显示。这些图像是硬写在应用程序中的(用于演示)。

我的应用程序在访问 Google Drive API 时遇到了问题。确实,经过多次尝试,随机请求出现了这个错误

User Rate Limit Exceeded. Rate of requests for user exceed configured project quota. You may consider re-evaluating expected per-user traffic to the API and adjust project quota limits accordingly. You may monitor aggregate quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?project=XXXXXXX"

所以我查看了 API 控制台,没有发现任何特殊情况,我没有超过我的速率限制。也许我用错了谷歌API,其实我不知道......

the bar on the right is my last try: 32 queries

我按照 Google Drive API 文档检查我是否做错了什么。对于每个 API 请求,请求都包含访问 token ,因此它应该可以正常工作!

应用演示可用:https://poc-drive-api.firebaseapp.com

源代码也可用:https://github.com/Mcdostone/poc-google-drive-api (文件 App.js)

最佳答案

403: User Rate Limit Exceeded是防洪。一个用户一次只能发出这么多请求。不幸的是,您正在查看的图表中未显示用户速率限制。该图实际上很难显示真实情况。 Google 会在后台进行测试,如果您超出了限制,就会排除错误。他们不需要在图表中实际向我们展示

403: User Rate Limit Exceeded

The per-user limit has been reached. This may be the limit from the Developer Console or a limit from the Drive backend.

{ "error": { "errors": [ { "domain": "usageLimits", "reason": "userRateLimitExceeded", "message": "User Rate Limit Exceeded" } ], "code": 403, "message": "User Rate Limit Exceeded" } }

Suggested actions:

  • Raise the per-user quota in the Developer Console project.
  • If one user is making a lot of requests on behalf of many users of a G Suite domain, consider a Service Account with authority delegation (setting the quotaUser parameter).
  • Use exponential backoff.

当您开始遇到此错误消息时,IMO 要做的主要事情是实现 exponential backoff这样您的应用程序将能够放慢速度并再次发出请求。

关于javascript - 谷歌驱动器 API 超出用户速率限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53652829/

相关文章:

google-drive-api - Google Drive API - 覆盖共享文件夹中的所有者

php - 如何检查文件夹是否已存在于谷歌驱动器中?

javascript - 如何使显示文本成为多语言?

javascript - EXT 边框布局 : error when adding panels

security - OAuth 2.0 是否总是需要在流程中使用浏览器

python - 访问 token 和刷新 token 在 Python 的 Google Plus 中提供无效授权?

google-api - 谷歌云资源管理器 API : Test IAM Permissions

javascript - 解析嵌套的 JSON 并以特定格式显示

javascript - 您是否应该在 Ajax 调用中更新数据库?

google-cloud-platform - 错误: 10: Developer console is not set up correctly (Not Using Firebase) (One Tap sign-up)