title: Google Drive API Wont Download Files
body: <p>I am trying to download the latest version of my software from google drive (I dont care about security, Im the only one running it, and im not sharing it), but it says the file is not found when its downloading.</p>
  <p>Here is my code:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  import re
  import sys
  import functions
  from functions import *
  import json
  from Google import Create_Service
  import io
  from googleapiclient.http import MediaIoBaseDownload
  
  versionList = []
  onlineVersionList = []
  version = &quot;&quot;
  
  
  #Google Api Stuff
  CLIENT_SECRET_FILE = 'client_secret_GoogleCloud.json'
  API_NAME = 'drive'
  API_VERSION = 'v3'
  SCOPES = ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.install']
  
  service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
  
  #Searches for the highest version on google drive
  page_token = None
  while True:
      response = service.files().list(q=&quot;mimeType = 'application/vnd.google-apps.folder' and  name contains 'Version'&quot;
                                        &quot;and not name contains 'ClockOS'&quot;,
                                            fields='nextPageToken, files(id, name)',
                                            pageToken=page_token).execute()
      for file in response.get('files', []):
          # Process change
          onlineVersionList.append(file.get('name'))
      page_token = response.get('nextPageToken', None)
      if page_token is None:
          break
  
  for filename in os.listdir('Versions'):
      if filename.startswith('Version'):
          versionList.append(filename)
          print(f&quot;Loaded {filename}&quot;)
  
  
  def major_minor_micro(version):
      major, minor, micro = re.search('(\d+)\.(\d+)\.(\d+)', version).groups()
  
      return int(major), int(minor), int(micro)
  
  def major_minor(version):
      major, minor, micro = re.search('(\d+)\.(\d+)\.(\d+)', version).groups()
  
      return int(major), int(minor)
  
  def major(version):
      major, minor, micro = re.search('(\d+)\.(\d+)\.(\d+)', version).groups()
  
      return int(major)
  
  
  if versionType() == &quot;stable&quot;:
      latest = str(max(versionList, key=major))
      onlineLatest = str(max(onlineVersionList, key=major))
  elif versionType() == &quot;standard&quot;:
      latest =  str(max(versionList, key=major_minor))
      onlineLatest = str(max(onlineVersionList, key=major_minor))
  elif versionType() == &quot;beta&quot;:
      latest = str(max(versionList, key=major_minor_micro))
      onlineLatest = str(max(onlineVersionList, key=major_minor_micro))
  else:
      print(&quot;An error has occurred and a wrong version type was picked.&quot;)
      sys.exit()
  
  if str(onlineLatest) &gt; str(latest):
      #Gets the api of the highest version
      page_token = None
      while True:
          response = service.files().list(q=f&quot;mimeType = 'application/vnd.google-apps.folder' and  name contains '{onlineLatest}'&quot;,
                                                fields='nextPageToken, files(id, name)',
                                                pageToken=page_token).execute()
          for file in response.get('files', []):
              # Process change
              print('Found file id: %s (%s)' % (file.get('name'), file.get('id')))
              onlineVersionID = file.get('name')
          page_token = response.get('nextPageToken', None)
          if page_token is None:
              break
  
      request = service.files().get_media(fileId=onlineVersionID)
      fh = io.BytesIO()
      downloader = MediaIoBaseDownload(fh, request)
      done = False
      while done is False:
          status, done = downloader.next_chunk()
          print
          &quot;Download %d%%.&quot; % int(status.progress() * 100)
  
  
  
  print(&quot;Ran&quot;, latest)
  setInfo(&quot;version&quot;, latest)
  
  os.chdir((&quot;Versions/&quot;+latest))
  cwd = os.getcwd()
  sys.path.append(cwd)
  
  import main
  </code></pre>
  <p>And I get this error, after I log into google:</p>
  <pre><code>googleapiclient.errors.HttpError: 
  &lt;HttpError 404 when requesting (link to file)?alt=media returned &quot;File not found: Version 0.1.1.&quot;. Details: &quot;[
  {'domain': 'global', 'reason': 'notFound', 'message': 'File not found: Version 0.1.1.', 
  'locationType': 'parameter', 'location': 'fileId'}
  ]&quot;&gt;
  </code></pre>
  <p>It clearly finds it, as it returns the name I gave it, so why wont it download, anyone know how to fix?
  I already gave it scopes needed, and gave my account tester, and this is stored in the same google account as the one I log into.</p>