Forums

praw-OAuth2Util Help needed

Trying to get a reddit bot ruining and i get this as an error. Any ideas?

 Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/praw/internal.py", line 213, in _raise_response_exceptions
    response.raise_for_status()  # These should all be directly mapped
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 840, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.reddit.com/api/v1/access_token/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 345, in refresh
    new_token = self.r.refresh_access_information(self._get_value(CONFIGKEY_REFRESH_TOKEN))
  File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 1492, in refresh_access_information
    refresh_token=refresh_token or self.refresh_token)
  File "<decorator-gen-11>", line 2, in refresh_access_information
  File "/usr/local/lib/python3.5/dist-packages/praw/decorators.py", line 288, in require_oauth
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 735, in refresh_access_information
    retval = self._handle_oauth_request(data)
  File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 659, in _handle_oauth_request
    response = self._request(url, auth=auth, data=data, raw_response=True)
  File "/usr/local/lib/python3.5/dist-packages/praw/__init__.py", line 454, in _request
    _raise_response_exceptions(response)
  File "/usr/local/lib/python3.5/dist-packages/praw/internal.py", line 215, in _raise_response_exceptions
    raise HTTPException(_raw=exc.response)
praw.errors.HTTPException: HTTP error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/Syndrogo/WIKI/UserListKeeper.py", line 228, in <module>
    run_bot()
  File "/home/Syndrogo/WIKI/UserListKeeper.py", line 190, in run_bot
    o = OAuth2Util.OAuth2Util(r)
  File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 157, in __init__
    self.refresh()
  File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 356, in refresh
    self._get_new_access_information()
  File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 254, in _get_new_access_information
    self._start_webserver(url)
  File "/home/Syndrogo/.local/lib/python3.5/site-packages/OAuth2Util/OAuth2Util.py", line 227, in _start_webserver
    self.server = HTTPServer(server_address, OAuth2UtilRequestHandler)
  File "/usr/lib/python3.5/socketserver.py", line 443, in __init__
    self.server_bind()
  File "/usr/lib/python3.5/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.5/socketserver.py", line 457, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address

It looks like it's trying to start an http server as part of the oauth process. That will not work in a PythonAnywhere console. Try using an auth method that doesn't need to start a server.