I am using googleapis
(drive v3) npm and oauth2client
to get drive items. I use drive.changes.getStartPageToken()
to create channel for webhooks(push notifications). I am successful in getting the notification. Now when I get the notification, initially was syncing all the drive items again. But now I wanted to change the flow as fetching only the changes in the drive using drive.changes.list()
. In drive.changes.list()
also should I get start page token again and hit it? what is the difference between the start page token that I use here and the start page token that I use when creating a channel? Is there any other way to fetch only changes of the files when webhooks hits us?
To use drive.changes.list()
you need to provide a pageToken generated by drive.changes.getStartPageToken()
. When you generate a startPageToken, all the future changes in your Drive will appear on drive.changes.list()
if you use that token.
After calling list()
, you need to get newStartPageToken from the response. Then you will send this newStartPageToken to get new changes and so on.
If you want to receive push notifications instead of requesting new changes everytime, I suggest you to read this article.