People API - QUOTA_EXCEEDED / FBS quota limit exceeded - google-api

The google people api page says correctly how to authenticate and list 10 example contacts and everything works perfectly:
https://developers.google.com/people/quickstart/python
I can authenticate and list 10 perfectly but I'm having an error when trying to create new contacts.
The api is returning me the following error:
HttpError: <HttpError 429 when requesting https://people.googleapis.com/v1/people:createContact?alt=json returned "Resource has been exhausted (e.g. check quota).". Details: "[{'#type': 'type.googleapis.com/google.rpc.QuotaFailure', 'violations': [{'subject': 'QUOTA_EXCEEDED', 'description': 'FBS quota limit exceeded.'}]}]">
when i click on https://people.googleapis.com/v1/people:createContact?alt=json, i have the following json on page:
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
I changed the scopes perfectly, even creating contacts a few months ago.
Out of nowhere everything stopped working and I'm having trouble QUOTA_EXCEEDED and FBS quota limit exceeded
I redid the entire authentication process and even tried to list contacts and without problems, everything works perfectly LESS the creation of contacts
Some observations:
I use via jupyter notebook and I'm also logged in to the email where
I want to create the contacts
I've tried to run in an IDE and the same problem
I've created 26888 contacts this way
This project does not appear on the Google console because I think I
did the entire project through documentation page, and I believe that the quotas have not been exhausted, just because I can see the values ​​correctly. I create on average 1 contact every 3 seconds and 200 contacts per day (maximum)
I would like a lot of help to know why I can't create more contacts, I have a lot of work pending because of that, thanks.
my code to create contacts:
def main():
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('people', 'v1', credentials=creds)
#----------------creatingc contacts----------------------
print('trying')
for i in df_banco_linhas[:2]:
if i[1] not in df_csv_linhas:
time.sleep(3)
service.people().createContact( body={
"names": [
{
"givenName": i[0]
}
],
"phoneNumbers": [
{
'value': i[1]
}
]
}).execute()
print('create: ' + i[0])
time.sleep(3)
else:
print('NO')
if __name__ == '__main__':
main()

As the problem was only happening when creating contacts, I decided to investigate the limit on the number of contacts and I came across the limit of 25000 in the documentation.
I was forced to create another email to solve the problem and increase my capacity to 50000 contacts (synchronizing two emails).
Their error message denotes that the problem is in the quota limit (requests), when in fact it is limit of contacts by email.

I was getting this same quota limit exceeded error ("FBS quota limit exceeded.") for a different reason. I was supplying values too long for the Organization.jobDescription field.
Perhaps this specific quota limit triggers when some non-rate constraints are violated, like total number of emails or maximum length of fields.
This may not be intended, since that kind of violation doesn't fit the 429 status code, and that limit is not listed in the Quotas section of the API/Service Details page for the People API in the console.

Related

Google.apis returns error code 400 after creating maximum amount of service account keys

We are using Google.apis Version 1.36.1 SDK in order to create service account keys for GCP Service accounts.
When we reach maximum amount of keys (10) instead of getting a valid error message / error code we recieve a general 400 error code with a "Precondition check failed." message.
We used to get error code 429 indicating we have reached maximum amount of keys.
Current GoogleApiException object :
Google.GoogleApiException: Google.Apis.Requests.RequestError
Precondition check failed. [400]
Errors [
Message[Precondition check failed.] Location[ - ] Reason[failedPrecondition] Domain[global]
]
The current return code does not provide us with enough information, Is there any other way for us to know the reason of the failure ?
This error message is also related to limits. You can take the official documentation for the Classroom API as an example.
I have found myself in a similar situation where we were deleting service account keys to immediately create new ones. We were getting the same error because there is a delay on the system where it can take from 60-90 seconds to delete the key for you to be able to create it again.

Rate limit exceeded - only used on one computer

I'm getting an error with Plaid that my rate limit has been exceeded, since I have 5 items in use on my developer account. I have only used Plaid on my localhost from my browser, and the quickstart app to look up my actual accounts. I'm confused how it thinks these are new systems - and also how to release one of these items so it frees up developer slots. The documentation says I can hit the release route, but that that doesn't restore an item slot.
Is there anything I'm missing?
{
"display_message": null,
"documentation_url": "https://plaid.com/docs/?ref=error#rate-limit-exceeded-errors",
"error_code": "ADDITION_LIMIT",
"error_message": "addition limit exceeded for this client_id. contact support to increase the limit.",
"error_type": "RATE_LIMIT_EXCEEDED",
"request_id": "#####",
"suggested_action": null
}
Ah yes you are not the first person to be confused by this! You need to request access to Development via the Plaid dashboard, which, once approved, will unlock access to 95 additional Items. You can do this here: https://dashboard.plaid.com/overview/development
The number of computers you are using doesn't matter, the only thing being counted is Items -- each Item takes up one slot, but in Development deleting Items does not free up slots.

Is there a place to get more granular reporting data via API?

I'm trying to figure out a way to export some of the events I can see in the security dashboard and alert center. The Customer Reports API only gives me the # of mail received per day, and # or spam messages per day, but is more than 24 hrs behind.
I've tried to create an alert in the security alerts center for whenever my domain gets a relevant email, but I just get an email once a minute that says the the threshold was exceeded, and I have to click into the investigation tool to actually get the relevant data.
Is there a place I can request # of phishing emails per hour, or be alerted whenever new phishing emails are found. Or Malware, etc.
The Reports API method UserUsageReport: get allows you to retrieve received spam emails for a certain date by specifying the parameter gmail:num_spam_emails_received
However, if you want to retrieve e.g. the emails from the last hour, there is no prebuilt functionality for this.
You can write a Google Apps Script that would browse your Gmail Inbox for new Spam Emails and set the script on a time-driven trigger
Sample:
function setmeOnHourlyTimer() {
var now = new Date();
var oneHourAgoinSeconds = Math.round(now.getTime()/1000 - 1200 *60);
var query = '"after:'+ oneHourAgoinSeconds +'"';
var spamMessages = Gmail.Users.Messages.list("YOU_EMAIL", {"labelIds": ["SPAM"] , "q": query}).messages;
if (spamMessages.length > 0){
GmailApp.sendEmail("paste your email here", "You have new Spam emails", "You got " + spamMessages.length + " new spam message(s) within the last hour.")
}
}

Unable to get results more than 100 results on google custom search api

I need to use Google Custom Search API https://developers.google.com/custom-search/v1/overview. From that page, it said:
For CSE users, the API provides 100 search queries per day for free.
If you need more, you may sign up for billing in the Developers
Console. Additional requests cost $5 per 1000 queries, up to 10k
queries per day.
I already sign up for billing inside the developer console. However, I still could not retrieve results more than 100. What things should I do more? https://www.googleapis.com/customsearch/v1?cx=CSE_INSTANCE&key=API_KEY&q=QUERY&start=100
{ error: { errors: [ { domain: "global", reason: "invalid", message:
"Invalid Value" } ], code: 400, message: "Invalid Value" } }
Query: Definition
https://support.google.com/customsearch/answer/1361951
Any actual user query from a Google Site Search engine, including but
not limited to search engines installed on your website using XML,
iFrame, or the Custom Search Element.
That means you would probably need to send eleven queries to get more than 100 results.
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=1
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=11
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=21
GET ...
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=81
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=91
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=101
Check every response and if error code is 400, you can stop - there is probably no need to send next (&start=previous+10) request.
Now you can merge responses and start building results page.
Google Custom Search and Google Site Search return up to 10 results
per query. If you want to display more than 10 results to the user,
you can issue multiple requests (using the start=0, start=11 ...
parameters) and display the results on a single page. In this case,
Google will consider each request as a separate query, and if you are
using Google Site Search, each query will count towards your limit.
There might be a better way to do this then I described above. (But, I'm not sure about batching API calls.)
And (finally) possible answer to your question: I made more than few tests, but I haven't had any luck with start greater than 100 (I was getting the same as you - <Response [400]>). I'm using "Browser key" from my billing-enabled project. That could mean we can't get 101st, 102nd, 103rd, etc. results with CSE API.
The API documentation says it never returns more than 100 items.
https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list
start
integer (uint32 format)
The index of the first result to return. The default number of results
per page is 10, so &start=11 would start at the top of the second page
of results. Note: The JSON API will never return more than 100
results, even if more than 100 documents match the query, so setting
the sum of start + num to a number greater than 100 will produce an
error. Also note that the maximum value for num is 10.

Random (403) User Rate Limit Exceeded

I am using translate API to translate some texts in my page, those texts are large html formated texts, so I had to develop a function that splits these texts into smaller pieces less than 4500 characters (including html tags) to avoid the limit of 5000 characters per request, also I had to modify the Google PHP API to allow send requests via POST.
I have enabled the paid version of the api in Goole Developers Console, and changed the total quota to 50M of characters per day and 500 requests/second/urser.
Now I am translating the whole database of texts with a script, it works fine but at some random points I revive the error "(403) User Rate Limit Exceeded", and I have to wait some minutes to re-run the script because when reached the error the api is returning the same error over and over until I wait some time.
I don't know why it keeps returning the error if I don't pass the number of requests, it's like it has some kind of maximum chaaracters per each interval of time or something...
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.
The 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
In my case, this error was caused by my invalid payment information. Go to Billing area and make sure everything is ok.

Resources