'“Invalid platform app” Error using Instagram Basic Display API

I am trying to use Instagram Basic display API but when I post the authorization code to get the access token I keep getting the following error. Can anyone help me out from this?

Error:

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid platform app"}

Code:

val url="https://api.instagram.com/oauth/access_token/" +
            "?client_id=${InstagramId}" +
            "&client_secret=${InstagramSecret}" +
            "&grant_type=authorization_code " +
            "&redirect_uri=${RedirectUrl}" +
            "&code=${code}"

AndroidNetworking.post(url)
        .build()
        .getAsJSONObject(object : JSONObjectRequestListener {
            override fun onResponse(response: JSONObject) {
                Log.d("_TAG_", "onResponse:217 $response")
            }

            override fun onError(error: ANError) {
                error.printStackTrace()
                Log.d("_TAG_", "onError:226 ${error.errorBody} - ${error.errorCode} - ${error.errorDetail} - ${error.response}")
            }
        })


Solution 1:[1]

I think you have to adjust the way you call. That error is when you dont send parameters in the way is waiting IG.

I leave an example with Axios. But you can traduce to your favourite api.

 const querystring = require('querystring'); 

//Make Object with params
const data = {
      client_id: 'xxxxxxx', 
      client_secret: 'xxxxxxxxxxx',
      grant_type: 'authorization_code', 
      redirect_uri: 'https://example.com/auth',
      code: 'xxxx'
}

//Make the Call
 axios.post("https://api.instagram.com/oauth/access_token", querystring.stringify(data))
.then(function (response) {
      console.log("OK", response.data);
 })
 .catch(function (error) {
      console.log(error);
 });

Solution 2:[2]

I got similar issue, I was using facebook app id and app secret instead of instagram app id and app secret. To get instagram app id and secret go to "Instagram Basic Display" section on the Facebook Developer site.

Solution 3:[3]

you are using the FACEBOOK APP ID and SECRET please make sure Go to the "Instagram Basic Display" section on the Facebook developers site then scroll down until you find the Instagram App ID & Secret.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 emmanuel sio
Solution 2 Anupam Chaplot
Solution 3 Shakeel Ahmed