In google document, when you check the revisions, it will shows for each revision, who was editing and what they had edit. Right now I am using https://developers.google.com/drive/api/v3/about-sdk to get the google drive information. Right now I can get most of the detail for google drive like all the files' id, name, how many revisions for each file. But there is a problem, for the revision.get() method I only able to get each revision's id, lastmodifiedUser,when they modify each revision. I can't get what changes they have made in each revision, neither the amount of words have been edit. In the developer website it provide some object that will shows the size of changes in revision. But it mentions that it only work for binary file in google drive. It also told us that you won't able to the google doc,sheet detail revision information. Does anyone know how to get the words changes from google drive revisions? This is the code to get the revision information.
from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
def main():
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('drive', 'v3', http=creds.authorize(Http()))
# Call the Drive v3 API
results = service.files().list(
pageSize=2, fields="nextPageToken, files(size,id, name)").execute()
items = results.get('files', [])
print(items)
response = service.changes().list(pageToken=1,
spaces='drive').execute()
for change in response.get('changes'):
# Process change
print( 'Change found for file: %s' % change.get('fileId'))
if 'newStartPageToken' in response:
# Last page, save this token for the next polling interval
saved_start_page_token = response.get('newStartPageToken')
page_token = response.get('nextPageToken')
results = service.revisions().list(
fileId='1KlrFKGxmqKMxjdEx-NoJ1ApG5qvlaKBMA7ZdVcITzGY',
).execute()
items = results
print(items,"\n")
if __name__ == '__main__':
main()