7

I've been following Instagram's basic guides here https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-access-tokens-and-permissions

I added my personal Instagram account as a tester and I got the authorization code, but when I send the request to get the access token, this is my response:

{
    "error_type": "OAuthException",
    "code": 400,
    "error_message": "Missing required field client_id"
}

This is my input in POSTMAN:

enter image description here

Any help or possible tips will greatly be appreciated, thanks in advance!

murp
  • 403
  • 5
  • 10
  • Seems to me the error message is pretty clear. It says **Missing required field client_id**, and the input you're providing does not include a value for **client_id**. – Ken White Dec 28 '20 at 01:46
  • I don't include it in the screenshot here bc i don't want to share my client id on stackoverflow @KenWhite hence the black box – murp Dec 28 '20 at 17:49

3 Answers3

28

I found the solution to my own question here Impossible to get an access_token for Instagram Basic Display API

When using Postman for Instagram's API, you should fill out the info required under the POST request's Body, NOT the Parameters. And when in the body, just select x-www-form-irlencoded

murp
  • 403
  • 5
  • 10
0

Just a clarification, you also have to keep "#_ at the end of the code for it to work (contrary to what the doc says)

Ubobby
  • 1
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31970220) – nvidot Jun 13 '22 at 15:02
0

rather than encoding the body - can use this approach for python.

import urllib3

def make_post_request(url, fields):
    http = urllib3.PoolManager()
    response = http.request(
        'POST',
        url,
        fields=fields
    )
    return response.data.decode('utf-8')

url = 'https://api.instagram.com/oauth/access_token'
fields = {
    'client_id': '1234',
    'client_secret': 'ad09c61ac39488fc446b4bc0f05fddc9',
    'grant_type': 'authorization_code',
    'redirect_uri': 'https://www.blabla.app/auth/',
    'code': '1234'
}

response = make_post_request(url, fields)
print(response)
johndpope
  • 5,035
  • 2
  • 41
  • 43