title: showing subfolders in google drive using python api
body: <p>I'm trying to list all folders(and subfolders) in google drive.</p>
  
  <p>My root folder has six subfolders in it. but my code is only showing files.</p>
  
  <pre><code>def credentials_from_file():
      """Load credentials from a service account file
      Args:
          None
      Returns: service account credential object
  
      https://developers.google.com/identity/protocols/OAuth2ServiceAccount
      """
  
      # https://developers.google.com/identity/protocols/googlescopes#drivev3
      SCOPES = [
          'https://www.googleapis.com/auth/drive'
      ]
      SERVICE_ACCOUNT_FILE = './auth_creds.json'
  
      credentials = service_account.Credentials.from_service_account_file(
          SERVICE_ACCOUNT_FILE, scopes=SCOPES)
  
  
      return credentials
  
  credentials = credentials_from_file()
  service = discovery.build('drive', 'v3', credentials=credentials)
  
  
  results = service.files().list(pageSize=10, fields="nextPageToken, files(id, name)").execute()
  items = results.get('files', [])
  
  if not items:
      print('No files found.')
  else:
      print('Files:')
      for item in items:
          print(u'{0} ({1})'.format(item['name'], item['id']))
  </code></pre>
  
  <p>How do I get it to tell me the subfolders as well?
  Thanks!</p>
  
  <p>UPDATE #1.  This is teh OAuth version.  It allows the browser to create a token, and then should run, but after the token is created, it freezes on execution:</p>
  
  <pre><code>from httplib2 import Http
  from oauth2client import file, client, tools
  from getfilelistpy import getfilelist
  
  SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
  
  store = file.Storage('token.json')
  creds = store.get()
  if not creds or creds.invalid:
      flow = client.flow_from_clientsecrets('rrc_crds.json', SCOPES)
      creds = tools.run_flow(flow, store)
  
  resource = {
      "oauth2": creds.authorize(Http()),
      "fields": "files(name,id)",
  }
  res = getfilelist.GetFileList(resource)  # or r = getfilelist.GetFolderTree(resource)
  print(res)
  </code></pre>