Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2021 20:11
What would you like to do?
OAuth2 Testing an API request to Google Calendar API
def test_api_request():
"""Tests an API request to Google Calendar."""
# grab the credentials from our flask session, in production
# you will probably store this in some persistent database per user
credentials = google.oauth2.credentials.Credentials(
# build the Google Calendar service which we use to represent the Google Calendar
gcal = build('calendar', 'v3', credentials=credentials)
# grabs Google Calendar events for the particular user who authorized the app
events_result ='primary',
maxResults=10, singleEvents=True).execute()
# return a JSON response to the front end that shows the results
return {
"msg": "successfully processed request",
"data": events_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment