title: Get list of all google sheets using gspread?
body: <p>Currently I can connect using gspread and create/share a spreadsheet. I can also read data from said spreadsheet but I have to request it by name. Is there a way to list of all spreadsheets shared with the OAuth account being used.</p>
  <p>I may not know all the names of the spreadsheets that will be shared with the account so I want to have them listed off programmatically if possible.</p>
  <p>All I have been able to do so far is select a sheet by name. But I need to be able to pull a list of all sheets shared with my <code>service_account</code>.</p>
  <p>Everything I have found so far online is related to getting a list of sheets in a workbook but not a list of all workbooks available.</p>
  <p>Documentation is welcome though all the stuff I have found so far has not helped.</p>
  <pre><code>import gspread
  from oauth2client.service_account import ServiceAccountCredentials
  import tkinter as tk
  
  
  class Main(tk.Tk):
      def __init__(self):
          super().__init__()
          self.rowconfigure(0, weight=1)
          self.columnconfigure(0, weight=1)
          self.geometry('1000x400')
          self.txt = tk.Text(self)
          self.txt.grid(row=0, column=0, sticky='nsew')
          self.scope = [&quot;https://spreadsheets.google.com/feeds&quot;, 'https://www.googleapis.com/auth/spreadsheets',
                        &quot;https://www.googleapis.com/auth/drive.file&quot;, &quot;https://www.googleapis.com/auth/drive&quot;]
          self.txt.insert('end', '{}\n'.format(self.scope))
          print('Scope: ', self.scope)
          self.after(2000, self.testing)
  
      def testing(self):
          creds = ServiceAccountCredentials.from_json_keyfile_name('creds.json', self.scope)
          client = gspread.authorize(creds)
  
          try:
              sh = client.create('Created By App')
              sh.share('my.account@workemail.com', perm_type='user', role='writer')
  
          except Exception as e:
              print('Error: ', e)
  
          try:
              print('Client: ', client)
              try:
                  self.txt.insert('end', '{}\n'.format('Running: client.list_permissions(&quot;TestingSheet&quot;)'))
                  self.txt.insert('end', '{}\n\n'.format(client.list_permissions(&quot;TestingSheet&quot;)))
              except Exception as e:
                  self.txt.insert('end', 'Error: {}\n\n'.format(e))
                  print('Error: ', e)
              try:
                  self.txt.insert('end', '{}\n'.format('Running: client.list_spreadsheet_files()'))
                  self.txt.insert('end', '{}\n\n'.format(client.list_spreadsheet_files()))
              except Exception as e:
                  self.txt.insert('end', 'Error: {}\n\n'.format(e))
                  print('Error: ', e)
              try:
                  self.txt.insert('end', '{}\n'.format('Running: client.session()'))
                  self.txt.insert('end', '{}\n\n'.format(client.session()))
              except Exception as e:
                  self.txt.insert('end', 'Error: {}\n\n'.format(e))
                  print('Error: ', e)
  
              # Find a workbook by name and open the first sheet
              # Make sure you use the right name here.
              sheet = client.open(&quot;TestingSheet&quot;).sheet1
              self.txt.insert('end', '{}\n\n'.format(sheet))
              print('Sheet: ', sheet)
              # Extract and print all of the values
              list_of_hashes = sheet.get_all_records()
              self.txt.insert('end', '{}\n\n'.format(list_of_hashes))
              print('list_of_hashes: ', list_of_hashes)
          except Exception as e:
              self.txt.insert('end', 'Error: {}\n\n'.format(e))
              print('Error: ', e)
  </code></pre>
  <p>creds.json is formated like this:</p>
  <pre><code>{
    &quot;type&quot;: &quot;service_account&quot;,
    &quot;project_id&quot;: &quot;XXXXXXXXXXXXXXXXXXXXXXXX&quot;,
    &quot;private_key_id&quot;: &quot;XXXXXXXXXXXXXXXXXXXXXXXX&quot;,
    &quot;private_key&quot;: &quot;-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXXXXX\n-----END PRIVATE KEY-----\n&quot;,
    &quot;client_email&quot;: &quot;project-service-account@XXXXXXXXXXXXXXXXXXXXXXXX.iam.gserviceaccount.com&quot;,
    &quot;client_id&quot;: &quot;XXXXXXXXXXXXXXXXXXXXXXXX&quot;,
    &quot;auth_uri&quot;: &quot;https://accounts.google.com/o/oauth2/auth&quot;,
    &quot;token_uri&quot;: &quot;https://oauth2.googleapis.com/token&quot;,
    &quot;auth_provider_x509_cert_url&quot;: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;,
    &quot;client_x509_cert_url&quot;: &quot;https://www.googleapis.com/robot/v1/metadata/x509/project-service-account@XXXXXXXXXXXXXXXXXXXXXXXX.iam.gserviceaccount.com&quot;}
  </code></pre>