praw-dev / praw

PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
http://praw.readthedocs.io/
BSD 2-Clause "Simplified" License
3.5k stars 460 forks source link

400 Bad Request on access token refresh #677

Closed l3d00m closed 7 years ago

l3d00m commented 7 years ago

Issue Description

If I try to refresh the access token using:

reddit_auth = praw.Reddit(user_agent="Twitter X-Poster by l3d00m")
reddit_auth.set_oauth_app_info(client_id="eoAG6V7plEDeAA", client_secret=api_keys.reddit_client_secret,
                               redirect_uri="http://127.0.0.1")
reddit_auth.refresh_access_information(api_keys.reddit_client_refresh)

I get an 400 Bad Request. Stacktrace:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\internal.py", line 213, in _raise_response_exceptions
    response.raise_for_status()  # These should all be directly mapped
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\requests\models.py", line 884, 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 "C:/git/pietsmiet_android/scripts/lol.py", line 52, in <module>
    submit_to_reddit("lol.de")
  File "C:/git/pietsmiet_android/scripts/lol.py", line 48, in submit_to_reddit
    reddit_auth.refresh_access_information(api_keys.reddit_client_refresh)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\__init__.py", line 1476, in refresh_access_information
    refresh_token=refresh_token or self.refresh_token)
  File "<decorator-gen-11>", line 2, in refresh_access_information
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\decorators.py", line 288, in require_oauth
    return function(*args, **kwargs)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\__init__.py", line 733, in refresh_access_information
    retval = self._handle_oauth_request(data)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\__init__.py", line 657, in _handle_oauth_request
    response = self._request(url, auth=auth, data=data, raw_response=True)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\__init__.py", line 452, in _request
    _raise_response_exceptions(response)
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\praw\internal.py", line 215, in _raise_response_exceptions
    raise HTTPException(_raw=exc.response)
praw.errors.HTTPException: HTTP error

The same code worked a month ago like a charm, I have no idea why this is happening. (I only generated a new access token using this method). Thanks for your help!

System Information

PRAW Version: 3.6.0 (and 3.4.0)
Python Version: 3.5.2
Operating System: Windows 10
l3d00m commented 7 years ago

Nevermind, I'm an idot. Sorry for the confusion. I forgot to do:

 access_information = r.get_access_information('code')