“Invalid platform app” Error using Instagram Basic Display API

白昼怎懂夜的黑 提交于 2021-01-27 07:41:48

问题


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}")
            }
        })

回答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);
 });


来源:https://stackoverflow.com/questions/63019404/invalid-platform-app-error-using-instagram-basic-display-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!