Random (403) User Rate Limit Exceeded

前提是你 提交于 2019-12-05 03:12:27

You probably exceed the quota limits you set before: this is either the daily billable or the limit on the request characters per second.

To change the usage limits or request an increase to your quota, do the following: 1. Go to the Google Developers Console "https://console.developers.google.com/". 2. Select a project. 3. On the left sidebar, expand APIs & auth. 4. Click APIs. 5. Click the name of an activated API you're interested in "i.e. The Translate API". 6. Near the top of the info page for the API, click Quota.

  • If you have the billing enabled, just click Quota and it will take you to the quota page where you can view and change the quota-related settings.

  • If not, clicking Quota shows information about any free quota and limits that apply to the Translate API.

Google Developer Console has a rate limit of 10 requests per second, regardless of the settings or limits you may have changed.

You may be exceeding this limit.

I was unable to find any documentation around this, but could verify it myself with various API requests.

You control the characters limitation but not the concurrency

You are either making more than 500 concurrent request/second or you are using another Google API that is hitting such concurrency limitation.

Referer header is not set by default, but it is possible to add the headers to a request like so:

$result = $t->translate('Hola Mundo', [
    'restOptions' => [
        'headers' => [
            'referer' => 'https://your-uri.com'
        ]
    ]
]);

If it makes more sense for you to set the referer at the client level (so all requests flowing through the client receive the header), this is possible as well:

$client = new TranslateClient([
    'key' => 'my-api-key',
    'restOptions' => [
        'headers' => [
            'referer' => 'https://your-uri.com'
        ]
    ]
]);

This worked for me!

[Reference] https://github.com/googleapis/google-cloud-php/issues/483

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