Getting Bad Request 400 while requesting for access token from refresh token Reddit API

892 Views Asked by At

Initially i'm getting access token for reddit api by using payload={'grant_type': 'client_credentials', 'duration': 'permanent'} and this gives me access_token as well as refresh token and by using this refresh token, request for access_token but gives me Bad request response.


url = "https://www.reddit.com/api/v1/access_token"

payload={'grant_type': 'refresh_token',
'refresh_token': '-_DdTnxTXtIVyoZPT9JzhUNq3bGRjRg'}
files=[

]
headers = {
  'User-Agent': 'winserp',
  'Authorization': 'Basic *************************************************************************'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Response: {'message': 'Bad Request', 'error': 400}

0

There are 0 best solutions below