事件webhook n Python/Django。授权

2024-05-04 09:17:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个api来获取,创建事件和更新事件太。。现在,我想得到推送通知,如果任何与会者接受了活动请求或拒绝它或做了任何修改。所以我按照链接https://developers.google.com/calendar/v3/push编写了如下代码。我想知道我是不是哪里出了问题。这里用户的电子邮件是我的日历ID。但我仍然得到400或401状态响应说授权错误

            event_notification = {
                "id": event['id'],
                "type": "web_hook",
                "address": "http://www.example.com/notifications"
            }`enter code here`
            url = "https://www.googleapis.com/calendar/v3/calendars/"+user_email+"/events/watch"
            response = requests.post(url=url, data=json.dumps(event_notification), headers={"Content-Type":"application/json","Authorization":"I HAVE ENTERED THE ACCESS TOKEN OF CURRENT USER"})

Tags: httpscomeventapiidjsonurl链接