title: Google Drive API with Python not allowing file download despite correct scopes being added
body: <p>I have followed the <a href="https://developers.google.com/drive/api/v3/quickstart/python" rel="nofollow noreferrer">quickstart</a> given by Google for using Python and I have used the appropriate scope as given by Google for downloading files from the Drive <a href="https://www.googleapis.com/auth/drive.readonly" rel="nofollow noreferrer">https://www.googleapis.com/auth/drive.readonly</a> but I keep getting the error of:</p>
  
  <blockquote>
    <p>googleapiclient.errors.HttpError: https://www.googleapis.com/drive/v3/files/1RWpLGCWldcJyVqa0tIVlScg60ExEtcNIvJ7R9M8DuhM?alt=media
    returned "Only files with binary content can be downloaded. Use Export
    with Google Docs files."</p>
  </blockquote>
  
  <p>When I try to run the code to download the files. </p>
  
  <p>I can read what files are on the drive, but I cannot seem to download a particular spreadsheet from the drive despite my best efforts. Here is my code (redacted file paths and some commenting) below for establishing the connection through the API:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>def gsuite_connect():
  
      file_path = 'OMITTED/Loading'
  
      # Get what permissions the user (using the API) will need. This as been set to high level
      # access by default
      scopes = ['https://www.googleapis.com/auth/drive.readonly']
      
      # Access the tokens for G Suite to access the Drive. Ensure that if this file previous exists,
      # that it is in the current working directory
      store = file.Storage(os.path.join(file_path, 'storage.json'))
      
      # Access the credentials for the Drive API
      creds = store.get()
      
      if not creds or creds.invalid:
          print("\nUsing credentials found in client_id(secret).json")
          flow = client.flow_from_clientsecrets(os.path.join(file_path, 'client_id.json'), scopes)
          creds = tools.run_flow(flow, store)
      
      http = creds.authorize(Http())
      drive = discovery.build('drive', 'v3', http=http)
      sheets = discovery.build('sheets', 'v4', http=http)
      
      return drive, sheets</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is the function (redacted file paths and some commenting) I use for downloading the files based on what <a href="https://developers.google.com/drive/api/v3/manage-downloads" rel="nofollow noreferrer">Google provides</a>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    def get_datalog(self):
  
          dir_path = 'OMITTED/Downloads'
          fname = "'FILENAME'"
          files = self.drive.files().list(q="name = {}".format(fname),
                                          fields="nextPageToken, files(id, name)").execute()
          items = files.get('files', [])
  
          # Error checking and subsequent downloading if file successfully found
          if not items:
              exit()
          else:
  
              # Change into the desired directory for storing the file and download file based on the
              # retrieved ID
              os.chdir(dir_path)
              file_id = items[0]['id']
  
              # Request download service
              request = self.drive.files().get_media(fileId=file_id)
  
              fh = io.FileIO(fname, mode='w')
              downloader = MediaIoBaseDownload(fh, request)
              done = False
              while done is False:
                  status, done = downloader.next_chunk()
                  print("Download %d%%." % int(status.progress() * 100))
  
              # Return the file path
              return os.path.join(dir_path, fname)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Help would be greatly appreciated! I do not want to show sensitive files such as the client_id.json or any other credentials but do let me know if you need further information!</p>