问题
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()
回答1:
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.
来源:https://stackoverflow.com/questions/61895430/people-api-quota-exceeded-fbs-quota-limit-exceeded