Nodejs instagram api发布请求authcode,它给错误400

时间:2018-01-13 04:21:22

标签: node.js https request

我正在尝试向Instagram发送帖子请求以获取访问令牌,但是当我发送它时,我得到错误400,这意味着语法错误。我使用错误的语法吗?

const request = require('request');
var formData = {
client_id: "theclientid",
client_secret: "thelcientsecret",
grant_type: "authorization_code",
redirect_uri: "http://localhost:3000/",
code: "thecode"
}
request.post({
    uri: "https://api.instagram.com/oauth/access_token",
    formData: formData,
    json: true
}, function(err, res, body) {
    console.log(err);
    console.log(res.statusCode);
    if (!err && res.statusCode == 200) {
        var user = JSON.parse(body);
        console.log(user);
    }
});

1 个答案:

答案 0 :(得分:0)

如果您打印响应正文,您将看到问题所在。

/images

试试另一个{ error_type: 'OAuthException', code: 400, error_message: 'Invalid Client ID' }