Reputation: 21
I am trying to use the drive API with push notifications that let me watch for changes to my file.
i follow the guide form google.
my steps :
Step 1: Verify that you own the domain done
Step 2: Register your domain done (i tried with multiple URL)
Creating notification channels
this is a simple node server for the webhook that i have deploy on the google app engine.
/* jshint node: true */
'use strict';
const key = require('./SBSWideDomainDev.json');
const google = require('googleapis');
const express = require('express');
var path = require("path");
const logging = require('./logging');
const app = express();
app.enable('trust proxy');
app.post('/notification', (req, res, next) => {
logging.info(res.body);
res.status(200).json(res.body);
});
if (module === require.main) {
var test = 8080;
const server = app.listen(test, () => {
const port = server.address().port;
console.log(`App listening on port ${port}`);
});
}
and i use live demo on the google page for file.watch
fileId : "some FileId",
request body:
{
"type": "web_hook",
"address": "https://notif-dot-sullivan-business-solution-dev.appspot.com/notification",
"id": "e64d0c44-f9a2-4db8-8d21-94ee0904dcb7"
}
Response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://notif-dot-sullivan-business-solution-dev.appspot.com/notification"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://notif-dot-sullivan-business-solution-dev.appspot.com/notification"
}
}
I absolutely don't have an idea where the problem is, i had follow the google guide exactly. And it's been three days i'm working on it.
(sorry for the bad english)
Upvotes: 2
Views: 651
Reputation: 201
Correct me if I am wrong - but I have used Goolge Drive API and to be able to successfully make request I had to generate OAuth token for my registered application. Have you registered one ? If not see here how to authenticate your application, google provides different ways to do it https://developers.google.com/drive/v3/web/about-auth.
After obtaining a token you should add it to your request as header property.
'Authorization': 'Bearer '.
Also keep in mind that google Oauth tokens expire in 1 hour after their generation and you should regenerate it.
Upvotes: 1