question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not all calendar events being returned by using `events().list`

See original GitHub issue

Environment details

  • OS type and version: MacOS Catalina 10.15.4
  • Python version: 3.7.5
  • pip version: 20.1.1
  • google-api-python-client version: 1.8.4

Steps to reproduce

  1. Create google service account
  2. Download credentials json
  3. Create a new calendar https://calendar.google.com/calendar/r
  4. Create 2 types of events, the specific hour event and the all day event
  5. Share that calendar with the service-account’s email
  6. Write down the id of the calendar Should look something like this: blablabla_j4h5k3jh5kj345kjh@group.calendar.google.com
  7. Add the contents of the credentials and the calendar id to the code example
  8. Run the example and it will return only 1 event (specific hour event), when expected 2, so all day event was missing from the response…

Code example

from google.oauth2 import service_account
from googleapiclient.discovery import build
from datetime import datetime, timedelta


def get_events(calendar_id: str, secrets: dict):
    SCOPES = ['https://www.googleapis.com/auth/calendar']
    SUBJECT = secrets['client_email']
    credentials = service_account.Credentials.from_service_account_info(
        secrets, scopes=SCOPES)
    delegated_credentials = credentials.with_subject(SUBJECT)
    service = build(
        'calendar', 'v3', credentials=delegated_credentials, cache_discovery=False)

    now = (datetime.utcnow() - timedelta(days=2)).isoformat() + 'Z'
    time_max = (datetime.utcnow() + timedelta(days=2)).isoformat() + 'Z'
    events = service.events().list(calendarId=calendar_id, timeMin=now, timeMax=time_max, maxResults=10,
                                   orderBy='startTime', singleEvents=True, showHiddenInvitations=True).execute()
    return events.get('items', [])


secrets = {
    # credentials goes here
}

calendarId = # your calendar id here

print(get_events(calendarId, secrets))

I’ve tried looking it up on google and stackoverflow, found nothing except that someone created a similar issue which was never really resolved. There fore I am creating a new issue with the code example.

Thank you! ❤️

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
busunkim96commented, Jun 17, 2020

Thanks for the update @WixoLeo! I’m sure it will help someone else running into the same issue.

The best place to raise product related bugs is the issue tracker.

0reactions
PenzinAlexandercommented, Feb 21, 2022

Hello everyone. Faced the same issue. Did someone got a solution for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Calendar list events method not returning any events
Google Calendar list events method not returning any events ... The Events: list is not returning all the events. I see a lot...
Read more >
Google Calendar API events list does not return al...
Hi, I have some python script that calls Google Calendar API events list with start and end set. It seems that there is...
Read more >
Events: list | Google Calendar
All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted...
Read more >
Common Problems with Google Calendar - Zapier Help
My events are being created for the wrong date and/or time · Are you creating an all-day event? · Are your timezone settings...
Read more >
List events - Microsoft Graph v1.0
For all GET operations that return events, you can use the Prefer: outlook.timezone header to specify the time zone for the event start...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found