title: Accessing Google spreadsheet with Python for server-to-server use
body: <p>I am trying to update a Google spreadsheet from a server that some target users can see on a daily basis. Here is what I tried:</p>
  
  <p>Created a project in "console.developers.google.com" then selected "drive API" -> "credentials" -> "add credentials" -> "service accounts" -> "create Json file"</p>
  
  <p>Now with this JSON file (<code>project name-e4sdfsdsdf0c.json</code>) I tried to access Spreadsheets.</p>
  
  <pre><code>import gdata.spreadsheet.service
  import gdata.service
  import urlparse
  import httplib2
  from oauth2client.file import Storage
  from oauth2client.client import flow_from_clientsecrets
  from oauth2client import tools
  spreadsheet_key = '13jQtgSUXKBExMvZjECf6sdfsfgLfmRFVmZw6t7hYyX3g0'
  storage = Storage("creds.dat")
  credentials = storage.get() 
  if credentials is None or credentials.invalid:
      credentials = tools.run_flow(flow_from_clientsecrets("project name-e4sdfsdsdf0c.json", scope=["https://spreadsheets.google.com/feeds"]), storage)
  if credentials.access_token_expired:
      credentials.refresh(httplib2.Http())
  
  spr_client = gdata.spreadsheet.service.SpreadsheetsService(
      additional_headers={'Authorization' : 'Bearer %s' % credentials.access_token})
  
  worksheets = spr_client.GetSpreadsheetsFeed(spreadsheet_key)
  print worksheets.title
  </code></pre>
  
  <p>But I am getting this error:  </p>
  
  <blockquote>
    <p>Invalid file format. See <a href="https://developers.google.com/api-client-library/python/guide/aaa_client_secrets" rel="nofollow">https://developers.google.com/api-client-library/python/guide/aaa_client_secrets</a> Expected a JSON object with a single property for a "web" or "installed" application"</p>
  </blockquote>