Drive API v2 (1.16) File Watch requests being denied when using Batch Request
See original GitHub issueHi,
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:
--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--
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();
Issue Analytics
- State:
- Created 7 years ago
- Comments:14
Top Results From Across the Web
Drive API v2 & v3 (1.16) File Watch requests being denied ...
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...
Read more >Resolve errors | Google Drive
Batch requests to make fewer API calls. Use exponential backoff to retry the request. Resolve a 403 error: Sharing rate limit exceeded. A ......
Read more >Improve performance | Google Drive
A batch request is a single standard HTTP request containing multiple Google Drive API calls, using the multipart/mixed content type. Within that main...
Read more >403 Permission Denied error when using Client_Secret.JSON ...
JSON file to connect to google spreadsheet API. ... Drive API v2 & v3 (1.16) File Watch requests being denied when using Batch...
Read more >Efficient File Management using Batch Requests ...
The issue is that batch requests aren't available for synchronous processes run through the Google Apps Script Drive service.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had an update from the developer support team.
Link to stack question File Watch requests being denied when using Batch Request