-, page_token, My Drive, . , .. :
def retrieve_all_files(service):
""" RETURNS a list of files, where each file is a dictionary containing
keys: [name, id, parents]
"""
query = "trashed=false"
page_token = None
L = []
while True:
response = service.files().list(q=query,
spaces='drive',
fields='nextPageToken, files(id, name, parents)',
pageToken=page_token).execute()
for file in response.get('files', []):
L.append({"name":file.get('name'), "id":file.get('id'), "parents":file.get('parents')})
page_token = response.get('nextPageToken', None)
if page_token is None:
break
return L