title: Error 403 when trying to upload file to google drive via python
body: <p>So I'm new to python (and this is a first post to stack overflow).  I'm trying to use python to upload and download files to and from a google drive account (and eventually reference files from this drive on a customized work tiki wiki).  The code below is from google's python api resources.  It will successfully list the files on my drive (as it should).  However, when I attempt to upload a file (see 10th line from bottom) I am given the following error:</p>
  
  <pre><code>An error occured: &lt;HttpError 403 "Insufficient Permission"&gt;
  </code></pre>
  
  <p>I've been looking around for a few hours now and I can't figure out how to get around this.  I'm thinking I need to request some sort of token.  Not really sure.  Again, I'm new to this.  Any help would be greatly appreciated!</p>
  
  <pre><code>import httplib2
  import os
  
  from apiclient import discovery
  import oauth2client
  from oauth2client import client
  from oauth2client import tools
  
  try:
      import argparse
      flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
  except ImportError:
      flags = None
  
  SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
  CLIENT_SECRET_FILE = 'client_secret.json'
  APPLICATION_NAME = 'Drive API Quickstart'
  
  
  def get_credentials():
      """Gets valid user credentials from storage.
  
      If nothing has been stored, or if the stored credentials are invalid,
      the OAuth2 flow is completed to obtain the new credentials.
  
      Returns:
          Credentials, the obtained credential.
      """
      home_dir = os.path.expanduser('~')
      credential_dir = os.path.join(home_dir, '.credentials')
      if not os.path.exists(credential_dir):
          os.makedirs(credential_dir)
      credential_path = os.path.join(credential_dir,
                                     'drive-quickstart.json')
  
      store = oauth2client.file.Storage(credential_path)
      credentials = store.get()
      if not credentials or credentials.invalid:
          flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
          flow.user_agent = APPLICATION_NAME
          if flags:
              credentials = tools.run_flow(flow, store, flags)
          else: # Needed only for compatability with Python 2.6
              credentials = tools.run(flow, store)
          print 'Storing credentials to ' + credential_path
      return credentials
  
  from apiclient import errors
  from apiclient.http import MediaFileUpload
  # ...
  
  def insert_file(service, title, description, parent_id, mime_type, filename):
    """Insert new file.
  
    Args:
      service: Drive API service instance.
      title: Title of the file to insert, including the extension.
      description: Description of the file to insert.
      parent_id: Parent folder's ID.
      mime_type: MIME type of the file to insert.
      filename: Filename of the file to insert.
    Returns:
      Inserted file metadata if successful, None otherwise.
    """
    media_body = MediaFileUpload(filename, mimetype=mime_type, resumable=True)
    body = {
      'title': title,
      'description': description,
      'mimeType': mime_type
    }
    # Set the parent folder.
    if parent_id:
      body['parents'] = [{'id': parent_id}]
  
    try:
      file = service.files().insert(
          body=body,
          media_body=media_body).execute()
  
      # Uncomment the following line to print the File ID
      # print 'File ID: %s' % file['id']
  
      return file
    except errors.HttpError, error:
      print 'An error occured: %s' % error
      return None
  
  def main():
      """Shows basic usage of the Google Drive API.
  
      Creates a Google Drive API service object and outputs the names and IDs
      for up to 10 files.
      """
      credentials = get_credentials()
      http = credentials.authorize(httplib2.Http())
      service = discovery.build('drive', 'v2', http=http)
  
      insert_file(service, 'picture.jpg', 'no_description', False, 'image/jpeg', '/Users/ethankay/Documents/Work/Current_Work/Astrophysics/Code/Logger_Program/Master/TestUploadFiles/test3.jpg')
  
      results = service.files().list(maxResults=10).execute()
      items = results.get('items', [])
      if not items:
          print 'No files found.'
      else:
          print 'Files:'
          for item in items:
              print '{0} ({1})'.format(item['title'], item['id'])
  
  
  
  
  if __name__ == '__main__':
      main()
  </code></pre>