1

I'm pretty sure I'm not converting the -F flags from the curl request incorrectly.

Here is the curl request:

curl -X POST \
  https://api.instagram.com/oauth/access_token \
  -F client_id=990602627938098 \
  -F client_secret=eb8c7... \
  -F grant_type=authorization_code \
  -F redirect_uri=https://socialsizzle.herokuapp.com/auth/ \
  -F code=AQCvI...

Here is my axios request:

try {
        const res = await axios.post(
          "https://api.instagram.com/oauth/access_token",
          {
            params: {
              client_id: "146179390",
              client_secret: "5436e5ca5ed29895e42c85825b",
              code: "6tPDoIMdkUbSWw",
              grant_type: "authorization_code",
              redirect_uri: "https://www.example.com/",
            },
          }
        );
        console.log(res);
      } catch (error) {
        console.log(error);
      }

I also tried:

const formdata = new FormData();

      formdata.append("client_id", "146179390");
      formdata.append("client_secret", "5a5ed29895e42c85825b");
      formdata.append(
        "code",
        "AQCkRliWFrgH1k"
      );
      formdata.append("grant_type", "authorization_code");
      formdata.append("redirect_uri", "https://www.example.com/");

      try {
        const res = await axios.post(
          "https://api.instagram.com/oauth/access_token",
          formdata
        );
        console.log(res);
      } catch (error) {
        console.log(error);
      }
Roger Staxx
  • 439
  • 4
  • 12
  • I'd be surprised if your `curl` command actually works. Using `-F` (according to the [curl man page](https://curl.se/docs/manpage.html#-F)) causes it to set the content-type to `multipart/form-data` however OAuth `/access_token` endpoints typically want the parameters as `application/x-www-form-urlencoded`. You should be using the `-d` option instead. – Phil Feb 24 '22 at 01:01

0 Answers0