I am trying to use the gspread python module to read google spreadsheet. But I get some error from ssl. I tried to learn this, but could not get it to work. The gspread module uses a python request , which appears to be using the python ssl package. The code (I wrote) and the stack trace are given below with env details.
Env:
- python: 2.7.13
- Ubuntu: 14.04
- openssl: 1.0.1f January 6, 2014
Code:
import gspread from oauth2client.client import SignedJwtAssertionCredentials scope = ['https://spreadsheets.google.com/feeds'] credentials = SignedJwtAssertionCredentials(user_email, private_key, scope) google_client = gspread.authorize(credentials) worksheet = google_client.open_by_url(<worksheet_url>).get_worksheet(1) list_of_rows = worksheet.get_all_values() print list_of_rows
Stack trace:
File "<console>", line 1, in <module> File "/home/nikhil/.venv/nikhil/src/gspread/gspread/models.py", line 344, in get_all_values cells = self._fetch_cells() File "/home/nikhil/.venv/nikhil/src/gspread/gspread/models.py", line 231, in _fetch_cells feed = self.client.get_cells_feed(self) File "/home/nikhil/.venv/nikhil/src/gspread/gspread/client.py", line 186, in get_cells_feed r = self.session.get(url) File "/home/nikhil/.venv/nikhil/src/gspread/gspread/httpsession.py", line 76, in get return self.request('GET', url, **kwargs) File "/home/nikhil/.venv/nikhil/src/gspread/gspread/httpsession.py", line 68, in request response = func(url, data=data, headers=request_headers, verify=False) File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 469, in get return self.request('GET', url, **kwargs) File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 457, in request resp = self.send(prep, **send_kwargs) File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 606, in send r.content File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/models.py", line 724, in content self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes() File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/models.py", line 653, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 256, in stream data = self.read(amt=amt, decode_content=decode_content) File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 186, in read data = self._fp.read(amt) File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 573, in read return self._read_chunked(amt) File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 642, in _read_chunked value.append(self._safe_read(chunk_left)) File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 688, in _safe_read chunk = self.fp.read(min(amt, MAXAMOUNT)) File "/usr/local/lib/python2.7.13/lib/python2.7/socket.py", line 384, in read data = self._sock.recv(left) File "/usr/local/lib/python2.7.13/lib/python2.7/ssl.py", line 766, in recv return self.read(buflen) File "/usr/local/lib/python2.7.13/lib/python2.7/ssl.py", line 653, in read v = self._sslobj.read(len) SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1864)
Any help would be greatly appreciated.
UPDATE: I configured everything from scratch on the new machine, and also updated my oauth client to use the new version of the API. Failed to do the above env job, so until this question is open.