Is get start Page Token for creating drive push notification channel and getting list of changes is same?

The name of the picture


Is get start Page Token for creating drive push notification channel and getting list of changes is same?



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?


googleapis


oauth2client


drive.changes.getStartPageToken()


drive.changes.list()


drive.changes.list()




1 Answer
1



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.


drive.changes.list()


drive.changes.getStartPageToken()


drive.changes.list()



After calling list(), you need to get newStartPageToken from the response. Then you will send this newStartPageToken to get new changes and so on.


list()



If you want to receive push notifications instead of requesting new changes everytime, I suggest you to read this article.





I have already implemented push notification. When I receive a push notification, I call the changes.list API to get changes. But I don't get appropriate changes. Now I'm facing an issue where the changes array is always empty and I get only newPagetoken for the initial request and not the next page token.
– Køusika Ganesh
1 hour ago





If you generate a newPagetoken and you use it on changes.list, you will only see changes after the token was generated. So you cannot generate a pageToken when you receive a push notification, maybe that's why you are receiving an empty array?
– Rubén López
1 hour ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP