googledrivewebhook没有任何

2024-09-29 06:24:42 发布

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

我使用python和google api python client==1.6.2与用户google Drive一起工作。一切工作都非常完美,没有任何bug,但我没有收到来自google Drive(Google Drive API Documentation)的任何推送通知。”注册你的域“成功完成”“创建通知通道”完成,通道对象返回给我。你知道吗

我的代码:

try:
    drive_service.files().watch(
        fileId='CPw3cbyqkoC1QMK48R24-Z2CG9w',
        body=dict(
            id=str(uuid.uuid4()),
            resourceId='CPw3cbyqkoC1QMK48R24-Z2CG9w',
            type='web_hook',
            address='https://my-domain-address/web_hook'
        )
    ).execute()
except HttpError as err:
    logger.exception('HttpError {}: content={}'.format(err.uri, err.content))

答复:

{
    u'resourceId': u'CPw3cbyqkoC1QMK48R24-Z2CG9w',
    u'kind': u'api#channel',
    u'expiration': u'1495448262000',
    u'id': u'8837a4ad-98c0-4e89-8899-c07e12e3bffc',
    u'resourceUri': u'https://www.googleapis.com/drive/v3/files/0B2lHB_g_GJY9RWx6UkRjWUFjSVU?acknowledgeAbuse=false&alt=json&supportsTeamDrives=false&alt=json'
}

之后,当用户修改监视的Google Drive资源时,没有任何对https://my-domain-address/web_hook的请求。你知道吗

你知道我做错了什么吗?你知道吗


Tags: 用户httpsapiwebidaddressgooglefiles
1条回答
网友
1楼 · 发布于 2024-09-29 06:24:42

记录与我在搜索解决方案时发现的问题相关的消息:

64.233.172.141 - - [22/May/2017:09:11:10 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"
64.233.172.143 - - [22/May/2017:09:11:12 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"
64.233.172.143 - - [22/May/2017:09:11:13 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"

所以我收到了对我的webhook的Google驱动请求。你知道吗

首先我认为Nginx正在阻止它们,但是在我看到所有请求都是POST之后。你知道吗

所以我开始考虑转发邮件请求的问题。我还使用了Django,忘记了禁用webhook的CSRF保护。这是我问题的解决办法。你知道吗

如果能帮上忙我会很高兴的。你知道吗

相关问题 更多 >