1

I have a server use google calendar API. But today i have a problem.

 <HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/9rmkucj5624ove5oe3dvlcchb8%40group.calendar.google.com/events/ilrgnanahon2scuq2hv9u6fcmg?alt=json returned "Calendar usage limits exceeded.">

The json

{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "errors": [
      {
        "message": "The request is missing a valid API key.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

But if i use API to creat events, edit events, API worked! My function to add attendee

def update_event_employee_email(service, calendarId, eventId, employee_email,displayName):
    # First retrieve the event from the API.
    event = service.events().get(calendarId=calendarId, eventId=eventId).execute()
    #print(event)
    add_attendees = {
        "displayName": str(displayName),
        "email": str(employee_email)
        }
    try:
        current_attendees = event['attendees']
    except Exception as e:
        current_attendees=[]
    if current_attendees:
        attendees = event['attendees']
        attendees.append(add_attendees)
        body = {
            "attendees": attendees
        }
        print(attendees)
    else:
        body = {
              "attendees": [
                {
                    "displayName": str(displayName),
                    "email": str(employee_email)
                }
              ]
            }
    #print(event)
    try:
        event = service.events().patch(calendarId=calendarId, eventId=eventId, body=body).execute()
        print(event)
        status = 200
    except Exception as e:
        print(json.loads(e.content)['error']['code'])
        status = 400
    return status

I also check the google support Avoid Calendar use limits

And i think my API doesnt over limit

Send too many invitations to external guests

I update: My service build code

# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/calendar']


def service_build():
    """Shows basic usage of the Google Calendar API.
    Prints the start and name of the next 10 events on the user's calendar.
    """
    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.
    print(os.path.exists('token.pickle'))
    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('calendar', 'v3', credentials=creds)
    return service
    # Call the Calendar API

So i guess my problem Ex: If you have a fresh token you can send any one *. 50 Events having 100 guest - 2 Guests per event *. 25 Events having 100 guest - 4 Guests per event

Limits per

Day: 36 Guests

Week: 252 Guests

Month: ~1080 Guests

So i also want to know, how to buy more limit to add more Guests

2
  • please include your authorization code where is service created. Commented Nov 3, 2020 at 7:45
  • thank you, i already updated, but when i creat new events, change time of events, ... etc, it is ok, but when i add attendee, problem come Commented Nov 3, 2020 at 7:51

1 Answer 1

0

The quota you list under Avoid Calendar use limits refers to the general usage of Google Calendar, if you are using the API opposed to UI), the quota limits are stricter.

Google does not provide exact information on the maximum quota for adding attendees via Calendar API usage, the available information is Google Calendar API Usage Limits:

The Google Calendar API has a courtesy limit of 1,000,000 queries per day.

To view or change usage limits for your project, or to request an increase to your quota, do the following:

  1. If you don't already have a billing account for your project, then create one.
  2. Visit the Enabled APIs page of the API library in the API Console, and select an API from the list.
  3. To view and change quota-related settings, select Quotas. To view usage statistics, select Usage.

In other words, you might be able to request extra quota for free, however, if you already increased the quota to the maximum allowance, you will not be able to obtain more quota - even paying.

Now to your second error message:

The request is missing a valid API key

This sounds like there is some problem with your authentication and the API assumes that you are trying to authenticate with an API key instead of a valid access token. To discard code implementation issues test your Events: insert or Events:patch request with the Try this API.

Sign up to request clarification or add additional context in comments.

6 Comments

I already check code, i have problem if i add 'attendees': [ {'email': str(email)}, ], Maybe the google think i spam email to send invitation to attendee? do you know how to solve this problem?
Do you have the problem when you create an event with attendees or when you update an existing event? Do you experience the same problem when adding attendees with the "Try this API"? Yes, it is possible that Google thinks that it is Spam - if you create too many events wiht too many attendees. I can recommend you to decrease the rate limit of oyur requests - e.g. with the exponential backoff.
Yes, i have problem: if creat new event or update by Patch method with attendee, google say that: "Calendar usage limits exceeded.", i add Try/Except to my code, try creat event with attendee have error, my system will creat new event with out attendee, it worked. In my website, i want to invite my employee to a job via google calendar, so i also want to add attendees, about 2 or 3 email for one events. Do you have solutions to google know that, i am not spammer, because i only invite my employee
In this case you exceeded your quota indeed. Have you tried to request an increase as recommended by the documentation? If you are a Google Workspace user, you can contact support and ask them to look into your quota issue.
Sure, this would be the best.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.