Below is the correct way to get the access token: client_id= 'my_client_id' client_secret = 'my_client_secret' data_string = f'{client_id}:{client_secret}' token = base64.b64encode(data_string.encode()) headers = { 'Authorization': 'Basic ' + token.decode('utf-8'), 'Content-Type': 'application/x-www-form-urlencoded', } url = "https://api.pinterest.com/v5/oauth/token" code = "my_code_that_i_got_in_the_first_step" data= { 'grant_type':'authorization_code', 'code': code, 'redirect_uri':'https://my_redirect_uri' } r = requests.post(url, headers=headers, data=data) print(r.json())In my question, I had mistyped redirect_uri as redirect_url. Also, when sending a POST, you should use data instead of params. See the comment by Amos Baker. (责任编辑:) |