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

312 Views Asked by At

I'm trying to use the reddit API to pull text data for a project, but I can't get the OAuth access token. Instead of responding with the access token, the response just says bad request.

Here's my code:

data={'grant_type':'authorization_code','code':'authcode which I got from the get request before','redirect_uri':'https://www.google.com/'}
r=requests.post('https://www.reddit.com/api/v1/access_token',data=data,auth=('client ID','client Secret'),headers={'User-Agent':'Rishi'})
print(r.text)

this what I'm getting

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

Triple checked the personal use script and secret, and so I'm struggling to think of what's wrong. Any ideas?

0

There are 0 best solutions below