1👍
✅
That is a strange way to format the data. You have each parameter in a separate dictionary. I guess you want a single dict:
data = {
'client_id': 'xxx',
'client_secret': 'xxx',
'grant_type': 'authorization_code',
'redirect_uri' : 'xxx',
'code': xxx
}
Also, you specify the content type as form-encoded, but you then serialize the actual data as JSON. Don’t do that.
r = requests.post(url, data=data, headers=headers)
Source:stackexchange.com