question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP errors - intermittent

See original GitHub issue

I’m getting intermittent HTTP errors when reading or (more frequently) writing to sheets. I moved to Gspread from GoogleCL, and I’ve been happy with ease and speed, but now I’m getting more of these errors. It works most of the time, but not consistently. Thanks in advance!

My code for writing is (essentially) here:

def SaveHistory(History, reassesslist, todaydict, date,did):
    username = '...'
    password = '...'
    sheetname = "Re"

    client = gspread.login(username, password)
    spreadsheet = client.open(sheetname)

    worksheet = spreadsheet.sheet1
    worksheet.resize(rows=1,cols=12)

    for row in reassesslist:
        worksheet.append_row(temp)    

The error (or at least the most recent one that I’ve gotten): Exception in Tkinter callback Traceback (most recent call last): File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gspread/client.py”, line 137, in open feed = self.get_spreadsheets_feed() File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gspread/client.py”, line 223, in get_spreadsheets_feed r = self.session.get(url) File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gspread/httpsession.py”, line 79, in get return self.request(‘GET’, url, **kwargs) File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gspread/httpsession.py”, line 75, in request raise HTTPError(response) HTTPError

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:32 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
burnashcommented, Apr 14, 2015

Yeah, this part of the ref needs more details.

You need to go to Google Developers Console. Create a new project (or select the one you have.)

credentials-page

Under “API & auth”, in the API enable “Drive API”.

enabled-apis

Go to “Credentials” and hit “Create new Client ID”.

Create Client ID

Select “Service account”. Hitting “Create Client ID” will generate a new Public/Private key pair. You will automatically download a JSON file with this data.

download-credentials

This is how this file looks like:

{
  "private_key_id": "2cd … ba4",
  "private_key": "-----BEGIN PRIVATE KEY-----\nNrDyLw … jINQh/9\n-----END PRIVATE KEY-----\n",
  "client_email": "473 … hd@developer.gserviceaccount.com",
  "client_id": "473 … hd.apps.googleusercontent.com",
  "type": "service_account"
}

You need client_email and private_key (yes, that’s a SIGNED_KEY)

Now you can read this file, and use the data when constructing your credentials:

import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials

json_key = json.load(open('gspread-april-2cd … ba4.json'))
scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
gc = gspread.authorize(credentials)

Don’t forget to share your spreadsheet with an email you have in your json_key['client_email'].

0reactions
burnashcommented, Apr 8, 2015

Good, I’m glad it helped you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intermittent http connection failure - Server Fault
Looking at the server's dom logs, no incoming requests are logged during the failures, so they are not actually reaching Apache as an...
Read more >
Intermittent HTTP 500 error codes occur when you access a ...
Fixes a problem in which intermittent HTTP 500 error codes occur when you access a Forefront Unified Access Gateway 2010 portal.
Read more >
Troubleshoot a Classic Load Balancer: HTTP errors
Description: Indicates that the load balancer closed a connection because a request did not complete within the idle timeout period. Cause 1: The...
Read more >
Intermittent 400 HTTP errors when pushing application in ...
CF CLI intermittently fails to push an application. If you enable the trace using the command bellow: $ CF_TRACE=true cf push app
Read more >
Intermittent Errors when using Client Applications in API ...
The Root Cause has been identified as the regression within the API Manager Deployment. MuleSoft Remediation Actions. Expand on the validation and monitoring...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found