Reputation: 1
We want to receive notifications from google when we do anychange(Add,Edit OR Delete) on google drive folder for these purpose we have integrated google watch api in our spring boot application.
code snippet :
public Channel setUpWatch() throws IOException, GeneralSecurityException {
Channel channel = new Channel();
channel.setAddress("https://somedomain.com/notifications");
channel.setType("web_hook");
channel.setId(UUID.randomUUID().toString());
channel.setKind("api#channel");
StartPageToken pageToken =
driveServiceProvider.getDriveService().changes().getStartPageToken().execute();
System.out.println(pageToken.getStartPageToken());
Channel changesChannel = driveServiceProvider.getDriveService().changes()
.watch(pageToken.getStartPageToken(), channel).execute();
System.out.println(changesChannel.getExpiration());return
return changesChannel;
}
After running this code we are getting 200 in response, but we are not receiving any push notification from google when we do any operation in google drive. We are getting empty changeList
We are checking this code on local with no domain registration
Is there any other way to get the edit, add or deleted files list from google drive?
We do not want any notification on any domain or address. Whenever we trigger the api and if any file(s) is changed, we want that file(s) details like drive url, file name.
Upvotes: 0
Views: 373
Reputation: 51
It seems that you are passing the current token to the changeList api. This will return no results. Actually, the solution is to find the changes since last token till the current token using a loop. So, store the last token somewhere and iterate till last token to current and pass the iterative value to chageList api to get the files changed.
Hope that works.
Upvotes: 1
Reputation: 116968
Push-notification channel will not send you requests for files inside a folder inside of a folder, just because you set up a watch on the folder itself.
To request push notifications, you need to set up a notification channel for each resource you want to watch.
If you preform a watch on a folder you will get a notification if for example the name of the folder is changed.
If you want to know if there are changes to a file then you will need to set up the watch for each of the files.
Upvotes: 0