Drive API v2& v3(1.16)使用批处理请求时,文件监视请求被拒绝

时间:2016-09-29 10:10:42

标签: google-drive-api

当我尝试在批处理请求中发出文件监视请求时,我收到403 watchDenied错误。通常发送它们很好。我假设允许批量处理File Watch请求?

附加信息:如果我设置了错误的地址,我会得到通常不允许的webhook地址错误,如果我设置了一个虚拟文件ID,我会得到一个404,所以我觉得我的请求不正确

示例代码(使用C#客户端库):

var request = new BatchRequest(service);
request.Queue<Channel>(service.Files.Watch(
    new Channel
    {
        Id = [Guid being used],
        Type = "web_hook",
        Address = [notification endpoint],
        Token = [token being used],
        Expiration = DateTime.Now.AddHours(1).ToUnixTimeMilliseconds()
    }, fileId)
    , (content, error, i, message) =>
    {

    }
);
await request.ExecuteAsync();

API请求

接头:

POST: https://www.googleapis.com/batch
User-Agent: OverDRIVE google-api-dotnet-client/1.16.0.0 (gzip)
Authorization: Bearer [token]
Content-Type: multipart/mixed; boundary="8d7a0653-4d9b-4c09-b701-9794341f882d"
Host: www.googleapis.com
Content-Length: 988
Accept-Encoding: gzip, deflate

体:

--8d7a0653-4d9b-4c09-b701-9794341f882d
Content-Type: application/http

POST https://www.googleapis.com/drive/v2/files/[fileId]/watch
Content-Type: application/json; charset=utf-8
Content-Length:  241

{"address":"[notification endpoint]","expiration":1474036096103,"id":"938bd983-b071-4e63-8535-f20d7f39e248","token":"[token being used]","type":"web_hook"}

--8d7a0653-4d9b-4c09-b701-9794341f882d
Content-Type: application/http

POST https://www.googleapis.com/drive/v2/files/[fileId]/watch
Content-Type: application/json; charset=utf-8
Content-Length:  241

{"address":"[notification endpoint]","expiration":1474036096105,"id":"79303874-5f6c-49aa-a601-93950895ac0f","token":"[token being used]","type":"web_hook"}

--8d7a0653-4d9b-4c09-b701-9794341f882d--    

错误示例

{
 "error": {
  "errors": [
   {
    "domain": "push",
    "reason": "watchDenied",
    "message": "Watch request denied by backend"
   }
  ],
  "code": 403,
  "message": "Watch request denied by backend"
 }
}       

1 个答案:

答案 0 :(得分:0)

我从开发人员支持团队获得了我提交给他们的机票的更新。

  

不幸的是,已知手表请求在很大程度上与之不兼容   驱动批量请求。我们的云团队建议制作手表   请求与其他请求分开。