python - Reddit PRAW Failing to autenticate due to SSL error -
my code this:
from bs4 import beautifulsoup urllib.parse import urlparse import requests import praw import time import re import bs4 useragent = 'web:peskytrollbot:v0.1 (by /u/redacted)' password = 'notreallymypassword' username = "peskytrollbot" id = 'redacted' secret = 'redacted' def authenitcate(): print("authenticating...") reddit = praw.reddit(client_id=id, client_secret=secret, password=password, user_agent=useragent, username=username) print("authenticated {}\n" .format(reddit.user.me())) return reddit authenitcate()
and console output (after having installed pyopenssl) follows:
c:\users\joshlaptop\appdata\local\programs\python\python36-32\python.exe c:/users/joshlaptop/pycharmprojects/practice/testbot.py authenticating... traceback (most recent call last): file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\contrib\pyopenssl.py", line 441, in wrap_socket cnx.do_handshake() file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\openssl\ssl.py", line 1716, in do_handshake self._raise_ssl_error(self._ssl, result) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\openssl\ssl.py", line 1456, in _raise_ssl_error _raise_current_error() file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\openssl\_util.py", line 54, in exception_from_error_queue raise exception_type(errors) openssl.ssl.error: [('ssl routines', 'tls_process_server_certificate', 'certificate verify failed')] during handling of above exception, exception occurred: traceback (most recent call last): file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\connectionpool.py", line 595, in urlopen self._prepare_proxy(conn) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\connectionpool.py", line 816, in _prepare_proxy conn.connect() file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect ssl_context=context) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\contrib\pyopenssl.py", line 448, in wrap_socket raise ssl.sslerror('bad handshake: %r' % e) ssl.sslerror: ("bad handshake: error([('ssl routines', 'tls_process_server_certificate', 'certificate verify failed')],)",) during handling of above exception, exception occurred: traceback (most recent call last): file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\requests\adapters.py", line 440, in send timeout=timeout file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in increment raise maxretryerror(_pool, url, error or responseerror(cause)) urllib3.exceptions.maxretryerror: httpsconnectionpool(host='www.reddit.com', port=443): max retries exceeded url: /api/v1/access_token (caused sslerror(sslerror("bad handshake: error([('ssl routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) during handling of above exception, exception occurred: traceback (most recent call last): file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\requestor.py", line 47, in request return self._http.request(*args, timeout=timeout, **kwargs) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\requests\sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\requests\sessions.py", line 618, in send r = adapter.send(request, **kwargs) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\requests\adapters.py", line 506, in send raise sslerror(e, request=request) requests.exceptions.sslerror: httpsconnectionpool(host='www.reddit.com', port=443): max retries exceeded url: /api/v1/access_token (caused sslerror(sslerror("bad handshake: error([('ssl routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) during handling of above exception, exception occurred: traceback (most recent call last): file "c:/users/joshlaptop/pycharmprojects/practice/testbot.py", line 19, in <module> authenticate() file "c:/users/joshlaptop/pycharmprojects/practice/testbot.py", line 16, in authenticate print("authenticated {}\n" .format(reddit.user.me())) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\praw\models\user.py", line 60, in me user_data = self._reddit.get(api_path['me']) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\praw\reddit.py", line 367, in data = self.request('get', path, params=params) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\praw\reddit.py", line 472, in request params=params) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 175, in request params=params, url=url) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 121, in _request_with_retries retries, saved_exception, url) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 87, in _do_retry params=params, url=url, retries=retries - 1) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 121, in _request_with_retries retries, saved_exception, url) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 87, in _do_retry params=params, url=url, retries=retries - 1) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 109, in _request_with_retries data, files, json, method, params, retries, url) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 94, in _make_request params=params) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\rate_limit.py", line 32, in call kwargs['headers'] = set_header_callback() file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\sessions.py", line 135, in _set_header_callback self._authorizer.refresh() file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\auth.py", line 328, in refresh password=self._password) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\auth.py", line 138, in _request_token response = self._authenticator._post(url, **data) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\auth.py", line 29, in _post data=sorted(data.items())) file "c:\users\joshlaptop\appdata\local\programs\python\python36-32\lib\site-packages\prawcore\requestor.py", line 49, in request raise requestexception(exc, args, kwargs) prawcore.exceptions.requestexception: error request httpsconnectionpool(host='www.reddit.com', port=443): max retries exceeded url: /api/v1/access_token (caused sslerror(sslerror("bad handshake: error([('ssl routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) process finished exit code 1
i have tried multiple suggestions other stackoverflow posts such updating useragent fit reddit guidelines one. have tried telling not verify ssl certificates right after created praw object , error still persists. tried using try catch loop minute sleep after each catch no avail. ideas troubleshooting? i've ran out of tips other posts making own.
Comments
Post a Comment