Getting File Metadata from Google API V3 in Python

Suppose you want to get the md5 hash of a file given its fileId, you can do it like this:

DRIVE = build('drive','v3', http=creds.authorize(Http()))
file_service = DRIVE.files()
remote_file_hash = file_service.get(fileId=fileId, fields="md5Checksum").execute()['md5Checksum']

To list some files on the Drive:

results = file_service.list(pageSize=10, fields="files(id, name)").execute()

I have built a small application gDrive-auto-sync containing more examples of API usage.
It's well-documented, so you can have a look at it if you want.
Here is the main file containing all the code. It might look like a lot but more than half of lines are just comments.


If you want to retrieve all the fields for a file resource, simply set fields='*'

In your above example, you would run

data = DRIVE.files().get(fileId=file['id'], fields='*').execute()

This should return all the available resources for the file as listed in: https://developers.google.com/drive/v3/reference/files