Search code examples
pythonsslgoogle-api-python-clientoauth2client

SSL error when using google-api-python-client init() method


  • python==3.8.2
  • google-api-python-client==1.6.5 1.9.3

Hello,

I'm having a SSL error when using google-api-python-client. Calling to sample_tools.init() for getting a service object triggers an error. This was working before I reinstalled Kubuntu and updated to python 3.8 (coming from 3.6.10).

I have googled but I can't find this exact error. I tried updating the version of the library, but didn't work and went back to the old one. Any piece of help, documentation or resource will be welcome, given that I have no clue what to try.

I have also tried used pyenv for making an additional alternative python install for 3.8.2 with python3-openssl and libssl-dev installed as described here and then a virtualenv inside PyCharm with that python. No luck.

This is the traceback:

Traceback (most recent call last):
  File "/home/madtyn/PycharmProjects/alfredBot/my_bot.py", line 427, in main
    reload_credentials()
  File "/home/madtyn/PycharmProjects/alfredBot/apis/blogger/blogger_insert.py", line 84, in reload_credentials
    service, flags = sample_tools.init(
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/googleapiclient/sample_tools.py", line 90, in init
    credentials = tools.run_flow(flow, storage, flags)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/tools.py", line 243, in run_flow
    credential = flow.step2_exchange(code, http=http)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/client.py", line 2053, in step2_exchange
    resp, content = transport.request(
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/oauth2client/transport.py", line 280, in request
    return http_callable(uri, method=method, body=body, headers=headers,
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 1322, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 1072, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/madtyn/venvs/alfred38/lib/python3.8/site-packages/httplib2/__init__.py", line 995, in _conn_request
    conn.connect()
  File "/usr/lib/python3.8/http/client.py", line 1409, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL] internal error (_ssl.c:1108)

Solution

  • Seems, the same issue exists in Google calendar too. There's a open bug submitted in the Google calendar github repo . It may take sometime to resolve this issue.

    Ref: https://github.com/home-assistant/core/issues/35870

    For now, You can install multiple python versions in the same machine. If you install them through, compile from source method. At the time of installation use make altinstall. This way you can point the previously working python version into you application and complete it. Once it resolved you can switch back to the newer version.