rckclmbr / pyportify

App to transfer your spotify playlists to Google Play Music
Apache License 2.0
779 stars 57 forks source link

Cannot connect to Spotify API #71

Open thaneofcawddor opened 8 years ago

thaneofcawddor commented 8 years ago

I am getting stuck on the OAuth Token page logging into Spotify.

` Error handling request Traceback (most recent call last): File "aiohttp/connector.py", line 581, in _create_connection File "asyncio/base_events.py", line 663, in create_connection File "asyncio/base_events.py", line 686, in _create_connection_transport File "asyncio/futures.py", line 358, in iter File "asyncio/tasks.py", line 290, in _wakeup File "asyncio/futures.py", line 274, in result File "asyncio/sslproto.py", line 492, in data_received File "asyncio/sslproto.py", line 200, in feed_ssldata File "ssl.py", line 628, in do_handshake ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aiohttp/connector.py", line 310, in connect File "aiohttp/connector.py", line 604, in _create_connection aiohttp.errors.ClientOSError: [Errno 1] Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aiohttp/server.py", line 266, in start File "aiohttp/web.py", line 90, in handle_request File "pyportify/app.py", line 64, in spotify_login File "pyportify/spotify.py", line 37, in loggedin File "pyportify/spotify.py", line 118, in _http_get File "aiohttp/client.py", line 528, in iter File "aiohttp/client.py", line 183, in _request File "aiohttp/connector.py", line 320, in connect aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host api.spotify.com:443 ssl:True [Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]] `

dawsome commented 7 years ago

Same issue here. OSX 10.11.6 Error handling request Traceback (most recent call last): File "aiohttp/connector.py", line 581, in _create_connection File "asyncio/base_events.py", line 713, in create_connection File "asyncio/base_events.py", line 736, in _create_connection_transport File "asyncio/futures.py", line 361, in iter File "asyncio/tasks.py", line 296, in _wakeup File "asyncio/futures.py", line 274, in result File "asyncio/sslproto.py", line 492, in data_received File "asyncio/sslproto.py", line 200, in feed_ssldata File "ssl.py", line 633, in do_handshake ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aiohttp/connector.py", line 310, in connect File "aiohttp/connector.py", line 604, in _create_connection aiohttp.errors.ClientOSError: [Errno 1] Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aiohttp/server.py", line 266, in start File "aiohttp/web.py", line 90, in handle_request File "pyportify/app.py", line 66, in spotify_login File "pyportify/spotify.py", line 39, in loggedin File "pyportify/spotify.py", line 120, in _http_get File "aiohttp/client.py", line 528, in iter File "aiohttp/client.py", line 183, in _request File "aiohttp/connector.py", line 320, in connect aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host api.spotify.com:443 ssl:True [Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]]

Creat commented 7 years ago

I have the same or a similar issue. It triggers when I'm trying to log into my google account, the credentials entered don't matter. System is centos 7.2.1511 with python 3.4.3 (at the moment)

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 238, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/util/ssl_.py", line 279, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.4/ssl.py", line 365, in wrap_socket
    _context=self)
  File "/usr/local/lib/python3.4/ssl.py", line 583, in __init__
    self.do_handshake()
  File "/usr/local/lib/python3.4/ssl.py", line 810, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/usr/local/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 574, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/aiohttp/server.py", line 261, in start
    yield from self.handle_request(message, payload)
  File "/usr/local/lib/python3.4/site-packages/aiohttp/web.py", line 88, in handle_request
    resp = yield from handler(request)
  File "/usr/local/lib/python3.4/site-packages/pyportify/app.py", line 45, in google_login
    token = yield from g.login(email, password)
  File "/usr/local/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/usr/local/lib/python3.4/site-packages/pyportify/google.py", line 27, in login
    res = gpsoauth.perform_master_login(username, password, android_id)
  File "/usr/local/lib/python3.4/site-packages/pyportify/gpsoauth/__init__.py", line 65, in perform_master_login
    return _perform_auth_request(data)
  File "/usr/local/lib/python3.4/site-packages/pyportify/gpsoauth/__init__.py", line 21, in _perform_auth_request
    headers={'User-Agent': useragent})
  File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 109, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
Creat commented 7 years ago

Well the source of the error for me seems to have been a bit silly: Python was built without SSL support, since it apparently builds silently without it if it can't find the OpenSSL-libs. I've rectified that and it's now working fine.

Would it be possible to add a check for this somewhere? A few semi-related uncaught exceptions on the console aren't exactly clear in this regard.

davidlavy88 commented 7 years ago

@Creat Can you explain how to do this please? To install Python I just did ~$ sudo apt-get install python3-pip I'm running Ubuntu

Creat commented 7 years ago

@davidlavy88 honestly I basically just googled it, too. If you've installed it from an official package, it should include SSL-Support already. It only doesn't if you compile it yourself and the headers aren't available.

If you do want to compile it yourself, first make sure OpenSSL headers are available. You can probably do this with:

sudo apt-get install libssl-dev

Then download the python sources (there's probably a dev package on ubuntu, no idea) and run a

./configure

with the options you want, then you can build/install with

make install

or use altinstall, depending on what if you want to overwrite the current installation or not.

As long as the OpenSSL sources are where they're supposed to be, configure should find them. If you downloaded the sources manually, you can specify it as an option to configure (--openssldir=/path). As for what options to call make with, there are plenty of "how to build python" tutorials, just look some of those up for details.

davidlavy88 commented 7 years ago

Awesome, I did a clean install and installed python 3.4 w ssl. Now it works and all my playlists exported successfuly!! =D

jasondanielsiegel commented 7 years ago

ok, i'm running into a similar issue. running os x, so python should be installed with all the appropriate sources, right?

if not, i'm lost! thanks in advance for any help. :)

My log in the terminal is similar to the OP:

Traceback (most recent call last): File "aiohttp/connector.py", line 306, in connect File "aiohttp/connector.py", line 585, in _create_connection File "aiohttp/connector.py", line 631, in _create_direct_connection aiohttp.errors.ClientOSError: [Errno 1] Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "aiohttp/server.py", line 265, in start File "aiohttp/web.py", line 96, in handle_request File "pyportify/middlwares.py", line 18, in index_handler File "pyportify/app.py", line 72, in spotify_login File "pyportify/spotify.py", line 38, in loggedin File "pyportify/spotify.py", line 118, in _http_get File "aiohttp/client.py", line 519, in iter File "aiohttp/client.py", line 165, in _request File "aiohttp/connector.py", line 316, in connect aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host api.spotify.com:443 ssl:True [Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]]

kbrta commented 7 years ago

sorry I'm not a coder, can some list a step by step for os x user to update openssl, python3 is showing OpenSSL 1.0.2k 26 Jan 2017 but python 2.7 is showing OpenSSL 0.9.8zh 14 Jan 2016, I've searched google but everyone keeps saying to brew link --force openssl which doesn't work Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

Stanzilla commented 7 years ago

The permissions needed for the oauth token are not enough, I cba to figure out which ones are needed apart from the two named in the wizard so I just selected all of them and then it worked

alexs77 commented 6 years ago

I'm using the pre-built 0.3.16 dmg from https://github.com/rckclmbr/pyportify/releases/download/v0.3.16/pyportify.dmg on OS X. I was able to login to Google (using an app password). But when I copy the OAUTH token from Spotify, in the shell where I started pyportify, there's then this:

Error handling request
Traceback (most recent call last):
  File "site-packages/aiohttp/connector.py", line 710, in _create_direct_connection
  File "asyncio/base_events.py", line 669, in create_connection
  File "asyncio/base_events.py", line 692, in _create_connection_transport
  File "asyncio/futures.py", line 385, in __iter__
  File "asyncio/tasks.py", line 288, in _wakeup
  File "asyncio/futures.py", line 274, in result
  File "asyncio/sslproto.py", line 486, in data_received
  File "asyncio/sslproto.py", line 200, in feed_ssldata
  File "ssl.py", line 628, in do_handshake
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "site-packages/aiohttp/connector.py", line 378, in connect
  File "site-packages/aiohttp/connector.py", line 687, in _create_connection
  File "site-packages/aiohttp/connector.py", line 737, in _create_direct_connection
aiohttp.client_exceptions.ClientConnectorError: [Errno 1] Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "site-packages/aiohttp/web_protocol.py", line 422, in start
  File "site-packages/aiohttp/web.py", line 306, in _handle
  File "pyportify/middlewares.py", line 18, in index_handler
  File "pyportify/app.py", line 72, in spotify_login
  File "pyportify/spotify.py", line 42, in loggedin
  File "pyportify/spotify.py", line 122, in _http_get
  File "site-packages/aiohttp/helpers.py", line 97, in __iter__
  File "site-packages/aiohttp/client.py", line 231, in _request
  File "site-packages/aiohttp/connector.py", line 383, in connect
aiohttp.client_exceptions.ClientConnectorError: [Errno 1] Cannot connect to host api.spotify.com:443 ssl:True [Can not connect to api.spotify.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)]]
bp32795 commented 6 years ago

I am having the exact same error thrown as @Creat , but I am on Windows, not Ubuntu. However, I can see the _ssl.lib in the libs folder and I installed Python 3.4 from a package, so I am not sure if that is what solved that issue, unless I am misunderstanding the solution.

inURwhey commented 6 years ago

I confirm that this issue occurred for me on OS X and was resolved by installing Python 3 per the instructions. (I had Python 2 installed, apparently, and that was not sufficient, and brew and xcode were both outdated, so it was actually kind of a rabbit hole, but whatever. I got it working in the end.)