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.

Google Calendar API Documentation Missing

See original GitHub issue

Environment details

  • OS: MacOS Catalina
  • Python version: 3.6.9
  • pip version: 19.3.1
  • google-api-python-client==1.7.11
  • google-auth-httplib2==0.0.3
  • google-auth-oauthlib==0.4.1
  • google-auth==1.10.1

Steps to reproduce

  1. It states here https://developers.google.com/calendar/v3/sync that a GoogleJsonResponseException will be returned in Java if a sync token can not be returned. Currently I have the following:
events = service.events().list(calendarId='primary', syncToken=sync_token, pageToken=page_token).execute()
except Exception as e:
    if 'code' in e and e.code == 410:	#sync token was invalidated, full sync required
        #clear token, call full sync

Is there documentation in python for how an invalidated sync token is handled?


  1. Is there python documentation that shows the client library automatically refreshing the access token after .execute()? For example, doing the following appears to show the client library automatically refreshing my access token:
credentials = pickle.loads(user.google_api_credentials)	
print(credentials.valid) #false
event_results = service.events().list(calendarId='primary', singleEvents=True).execute()
print(credentials.valid) #true after calling .execute() in the line above. 

Does this confirm using the python library will guarantee automatic refreshing of the access_token without requiring extra code?


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jason-cecommented, Jun 12, 2020

Try these imports:

from googleapiclient.errors import HttpError
from google.auth.exceptions import RefreshError

To the best of my knowledge, RefreshError happens when the sync token is invalided for any number of reasons such as the user changes their password, manually revokes permissions, or they’ve used the same token for 6 months.

You’ll need to account for RefreshError in your code as well. When we get a RefreshError, we sign them out of google calendar and give the user a message that they need to reconnect.

0reactions
danlo9commented, Jun 12, 2020

@jason-cf Thanks. This might be a silly question, but what is RefreshError?

Also, when I do

try:
    service.events().list(calendarId="primary", syncToken=sync_token, pageToken=page_token).execute()
except urllib.error.HTTPError as e:
    print(e.resp.status)

I am still not catching the error. Is there something I am missing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle API errors | Google Calendar
The rest of this page provides a reference of Calendar errors, with some guidance on how to handle them in your app. We...
Read more >
Google Calendar - SyncToken is missing in API response
This is why the nextSyncToken is not showing up. As mentioned on the documentation on Events: list -> Parameters -> syncToken : Token...
Read more >
Google Calendar ... calendars lost and no summary/name ...
Since we use the calendar for business scheduling, it is actually a very bad situation. I found out when using https://developers.google.com/apis-explorer/#p/ ...
Read more >
Authenticate using API keys - Google Cloud
Document processing and data capture automated at scale. Product Discovery. Google-quality search and product recommendations for retailers. APIs and ...
Read more >
Google Calendar API Documentation
Swagger documentation To access the Google Calendar API Swagger documentation directly, navigate to Google Calendar API Documentation .
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