问题
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