I need to send a POST request to the Instagram Basic API with Flask.
This is my code:
def get_token_insta(code):
dict_to_send = {"client_id": "XXX",
"client_secret": "XXX",
"grant_type": "authorization_code",
"redirect_uri": "XXX",
"code": "XXX"}
json_string = json.dumps(dict_to_send)
res = requests.post('https://api.instagram.com/oauth/access_token', data=json_string)
data = res.json()
print(data)
# More code...
The code works fine, but the response from Instagram is
{ "error_type": "OAuthException", "code": 400, "error_message": "Missing required field client_id" }
Reading the official documentation and this @murp answer I need to put data inside the body of the POST request.
Am I wrong? How can I make that work?