Nodejs instagram api post requesting authcode and it gives err 400

I am trying to send a post request to instagram to get an access token but when I send it I get err 400 which means bad syntax. Am I using bad syntax?

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

1 answer

  • answered 2018-01-13 04:21 Nikola Andreev

    If you print the response body you will see what the problem is.

    { error_type: 'OAuthException',
      code: 400,
      error_message: 'Invalid Client ID' }

    Just try another client_id.