title: Getting File Metadata from Google API V3 in Python
body: <p>I am trying to retrieve file metadata from Google drive API V3 in Python. I did it in API V2, but failed in V3.
  I tried to get metadata by this line:</p>
  
  <pre><code>data = DRIVE.files().get(fileId=file['id']).execute()
  </code></pre>
  
  <p>but all I got was a dict of <code>'id'</code>, <code>'kind'</code>, <code>'name'</code>, and <code>'mimeType'</code>. How can I get <code>'md5Checksum'</code>, <code>'fileSize'</code>, and so on?</p>
  
  <p>I read the <a href="https://developers.google.com/resources/api-libraries/documentation/drive/v3/python/latest/drive_v3.files.html#get" rel="noreferrer">documentation</a>.
  I  am supposed to get all the metadata by <code>get()</code> methods, but all I got was a small part of it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>from __future__ import print_function
  import os
  
  from apiclient.discovery import build
  from httplib2 import Http
  from oauth2client import file, client, tools
  
  try:
      import argparse
      flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
  except ImportError:
      flags = None
  
  SCOPES = 'https://www.googleapis.com/auth/drive.metadata
  https://www.googleapis.com/auth/drive'
  store = file.Storage('storage.json')
  creds = store.get()
  if not creds or creds.invalid:
      flow = client.flow_from_clientsecrets('storage.json', scope=SCOPES)
      creds = tools.run_flow(flow, store)
  DRIVE = build('drive','v3', http=creds.authorize(Http()))
  
  files = DRIVE.files().list().execute().get('files',[])
  
  for file in files:
      print('\n',file['name'],file['id'])
      data = DRIVE.files().get(fileId=file['id']).execute()
      print('\n',data)
  
  print('Done')
  </code></pre>
  
  <p>I tried this answer:
  <a href="https://stackoverflow.com/questions/35143283/google-drive-api-v3-migration">Google Drive API v3 Migration</a></p>
  
  <blockquote>
    <h2>List</h2>
    
    <p>Files returned by <code>service.files().list()</code> do not contain information now, i.e. every field is null. If you want list on v3 to behave like in v2, call it like this:</p>
    
    <blockquote>
  <pre><code>service.files().list().setFields("nextPageToken, files");
  </code></pre>
    </blockquote>
  </blockquote>
  
  <p>but I get a Traceback:</p>
  
  <pre><code>DRIVE.files().list().setFields("nextPageToken, files")
  AttributeError: 'HttpRequest' object has no attribute 'setFields'
  </code></pre>