I am trying to get a long-lived access token from the Instagram graph API through a python script. No matter what I do, I keep receiving the following error:

{"error":{"message":"Missing client_id parameter.","type":"OAuthException","code":101,"fbtrace_id":"AogeGpzZGW9AwqCYKHlmKM"}} 

My script is the following:

import requests refresh_token_url = 'https://graph.facebook.com/v19.0/oauth/access_token' payload = {     'grant_type': 'fb_exchange_token',      'client_id': '1234567890123456'     'client_secret': '1234abcd1234abcd1234abcd',         'fb_exchange_token':'abcd1234' } r = requests.get(refresh_token_url, data=payload) 

I am for sure passing the client_id parameter. I verified also by printing r.request.body

On the contrary, the request is successful if I send it with the Postman app:

Why do I keep getting that error message? Thank you!

Tag:python, facebook-graph-api, python-requests, instagram-api, instagram-graph-api

Only one comment.

  1. Bench Vue

    The Postman called by GET parameters.

    In modified version, the params argument is used instead of data. This change will append the parameters in payload to the URL as a query string,

    So your code needs to change it

    import requests refresh_token_url = 'https://graph.facebook.com/v19.0/oauth/access_token' payload = { 'grant_type': 'fb_exchange_token', 'client_id': '1234567890123456', 'client_secret': '1234abcd1234abcd1234abcd', 'fb_exchange_token': 'abcd1234' } r = requests.get(refresh_token_url, params=payload)

Add a new comment.