Hi,
I'm getting 403 watchDenied errors when I try to make File Watch requests in a Batch Request. Sending them normally is fine. I'm presuming that batching of File Watch requests is permitted?
Additional info: If I set an incorrect Address, I get the usually unpermitted webhook address error, so it doesn't feel like the request I'm making is incorrect.
Example code:
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 Request
Headers:
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
Body:
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--
API Response
Body:
HTTP/1.1 200 OK
Vary: Origin
Vary: X-Origin
Content-Type: multipart/mixed; boundary=batch_jD6q9aXFJBE_AAETSE-Oc84
Date: Fri, 16 Sep 2016 13:18:31 GMT
Expires: Fri, 16 Sep 2016 13:18:31 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
Content-Length: 1005
--batch_jD6q9aXFJBE_AAETSE-Oc84
Content-Type: application/http
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 16 Sep 2016 13:18:31 GMT
Expires: Fri, 16 Sep 2016 13:18:31 GMT
Cache-Control: private, max-age=0
Content-Length: 210
{
"error": {
"errors": [
{
"domain": "push",
"reason": "watchDenied",
"message": "Watch request denied by backend"
}
],
"code": 403,
"message": "Watch request denied by backend"
}
}
--batch_jD6q9aXFJBE_AAETSE-Oc84
Content-Type: application/http
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 16 Sep 2016 13:18:31 GMT
Expires: Fri, 16 Sep 2016 13:18:31 GMT
Cache-Control: private, max-age=0
Content-Length: 210
{
"error": {
"errors": [
{
"domain": "push",
"reason": "watchDenied",
"message": "Watch request denied by backend"
}
],
"code": 403,
"message": "Watch request denied by backend"
}
}
--batch_jD6q9aXFJBE_AAETSE-Oc84--
If I send a normal request such as the below, then all is OK.
Channel channel = new Channel()
{
Id = [Guid being used],
Type = "web_hook",
Address = [notification endpoint],
Token = [token being used],
Expiration = DateTime.Now.AddHours(1).ToUnixTimeMilliseconds()
};
service.Files.Watch(channel, fileId).Execute();
Ok i haven't actually tried this. I did play with watch a few years ago. I have used batching a bit but it was also a long time ago.
That being said "batching" of watch should be possible I have found no information that says its not. I also cant find a bug report on the issue forum.
Now then the error you are getting "403 request denied by backend" If you check the Error list you will notice most of the 403 errors have to do with speed. It makes me think there is a problem with drive processing the batch to fast. This seams unlikely as it would be an error on Googles side IMO. I haven't been able to find any reference to "Watch request denied by backend"
The only thing I can suggest would be to try and send it without the client library code this manually yourself. If you can get it to work then its probably a bug in the client library and something we can look into fixing. Basically we need to know if batching is in fact possible with watch or not.
Also have you consider switching to the V3 API and see if it works there? If it is a bug in V2 i think its unlikely they will bother to fix it.
If you can try this with the v3 api that would be helpful.
As Linda says, if it _is_ a server-side bug it's much more likely to get attention if it's in v3.
I would run thought the bug in V2 manually myself; mainly because i love reporting bugs to Google. However I am in the middle of a project and wont have time to look at it for a while.
@LindaLawton apologies for the delay, I've been unable to get back on this. I did try re-running the request via Fiddler separately, but obviously this would've been the same output generated by the library.
I'll create a mini-project to test v3 to see if it works. Thanks for yours and Chris' time.
@LindaLawton @chrisdunelm I've tested with v3 and I get the same response. If you like I could send over the test VS2015 project which uses v3 so you can use & test it for yourself. If that is useful to you let me know how you'd like to get the project.
Is there any update/acknowledgement of this issue?
It does sound like it's more likely to be a service-specific issue than a .NET client library one unfortunately Chris and I don't know much about the Drive SDK specifically.
I suspect if you ask with a short but complete program either in Stack Overflow using the google-drive-sdk tag or in the Drive API G+ community you're more likely to get answers to Drive-specific problems.
(Including the API request and body as you did at the start for the v2 API will definitely be appreciated.)
OK, that makes sense if it's not library related. I'll do that, thanks.
Link to stack question File Watch requests being denied when using Batch Request
Had an update from the developer support team.
Unfortunately watch requests are known to largely incompatible with Drive batch requests. Our Drive team recommended to make watch requests separate from other requests.
Thanks for the update.