I’m using google service account for the push notification to get in my console so I can handle it afterwards ,I’ve set up the credentials, put a watch on my drive root folder and watching any changes happens on my ngrok url which is https url of localhost 3000 but the problem is after I run the program it showed me that it has successfully put a watch but I’m not getting any notification even though I have made changes (uploaded some images)
this is my code for the reference
// googlpis set up
const { google } = require("googleapis")
const { v4: uuidv4 } = require("uuid")
const path = require("path")
const credentials = path.resolve(__dirname, "../googleKey.json")
const auth = new google.auth.GoogleAuth({
keyFile: credentials,
scopes: ["https://www.googleapis.com/auth/drive"]
})
const drive = google.drive({ version: "v3", auth })
//watch on my drive
async function setUpPushNotification() {
const response = await drive.files.watch({
fileId: "root",
requestBody: {
id: uuidv4(),
type: "web_hook",
address: "https://0642-202-189-239-146.ngrok-free.app/",
payload: true
}
})
console.log("Push notification channel set up:", response.data)
}
//console log
Push notification channel set up: {
kind: 'api#channel',
id: '57adb753-5ccb-4782-83b3-82532e1e147a',
resourceId: 'qHo857F_9Dp6NQ-zRAwcxdiGkw4-js',
resourceUri: 'https://www.googleapis.com/drive/v3/files/root?alt=json&null',
expiration: '1684133269000'
}
I have tried going through all the document related drive watch but not found any good solution even chat gpt does not able to resolve this problem.
I have tried to use different api for example create file api to upload something on drive and I successfully able to upload a image on my folder, so the set up is correct.
I’m expecting a response when I upload images on my drive, I should able to get the details like which image is uploaded when, where , by who etc.
ultimately I have to get that image which is uploaded and again upload it on my AWS account, but from the document It seems I cannot get the the image directly through notification so I have to run another api to get the image