0

I want to setup a push notification for the user's calendarID per the doc.

@blueprint.route("/notifications", methods={'GET','POST'})
def timeBlocker():
    email = request.json.get('email')
    user = User.query.filter_by(email=email).first()
    acessToken = accessToken(email, user.refresh)
    body = {
        'id': '01234567-89ab-cdef-0123456789ab', 
        'type': 'web_hook',
        'address': 'https://<registeredDomain>/notifications'
    }
    headers = {'Authorization': 'Bearer ' + acessToken,
            'Content-Type': 'application/json'
            }
    calendarID = '...@group.calendar.google.com'
    req = requests.post(url=f'https://www.googleapis.com/calendar/v3/calendars/{calendarID}@group.calendar.google.com/events/watch', data = json.dumps(body), headers=headers) 
    return str(req.json())

However, I keep on getting:

{'error': {'errors': [{'domain': 'global', 'reason': 'notFound', 'message': 'Not Found'}], 'code': 404, 'message': 'Not Found'}}

which isn't meaningful. At the same time, the doc gives such code as an example:

POST https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch
Authorization: Bearer auth_token_for_current_user
Content-Type: application/json

with my_calendar@gmail.com taken a calendarID when in reality the calendarIDs I've been receiving all end with @group.calendar.google.com. Thus, I am not sure if this is causing the case but keen to know how I shall fix the error.

Daniyal dehleh
  • 2,314
  • 2
  • 7
  • 22

0 Answers0