android - “Invalid platform app” 使用 Instagram 基本显示 API 时出错

标签 android kotlin instagram instagram-api

我正在尝试使用 Instagram 基本显示 API,但是当我发布授权代码以获取访问 token 时,我不断收到以下错误。谁能帮我解决这个问题?
错误:

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid platform app"}
代码:
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}")
            }
        })

最佳答案

我认为你必须调整你打电话的方式。该错误是当您不以等待 IG 的方式发送参数时。
我用 Axios 举个例子。但是你可以引用你最喜欢的 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);
 });

关于android - “Invalid platform app” 使用 Instagram 基本显示 API 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63019404/

相关文章:

Android 7.0 和 7.1 getApplication() ClassCastException

java - 以编程方式设置 PercentageRelativeLayout 中的宽高比

java - Android 应用程序在尝试打开 SettingsFragment 后崩溃

java - 带有产品 flavor 和 Kotlin 的 ClassNotFoundException

android - 如何在 Android 上为 ImageMagick 编译 Ghostscript?

android - 检查Android应用程序是否是您的或被反编译假冒

Kotlin - var 与对象声明之间的区别

Instagram API : Client is no longer active

javascript - 正确显示 Instagram 日期

android - 如何在像 instagram 这样的圆形 ImageView 周围设置边框?