如何解决Google 日历推送通知:“原因”:“未找到”
我想根据 doc 为用户的 calendarID
设置推送通知。
@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())
然而,我不断得到:
{'error': {'errors': [{'domain': 'global','reason': 'notFound','message': 'Not Found'}],'code': 404,'message': 'Not Found'}}
没有意义。同时doc给出这样的代码作为例子:
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
使用 my_calendar@gmail.com 获取了一个日历 ID,而实际上我收到的日历 ID 都以 @group.calendar.google.com 结尾。因此,我不确定这是否是导致这种情况的原因,但很想知道我将如何修复错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。