3

I followed with success the "first steps" guide here to test the Instagram API.

I did it as suggested in the docs with an heroku app.

Now that I obtained my access token, I would like to test this NodeJS Instagram private API on my local machine, without having to deploy on Heroku only for development purposes all the time I make changes.

In practice, I would like to test it with localhost, instead of myapp.herokuapp.com.

I thought to add a redirect OAuth URI like https://localhost:8443/auth/ in the section of the image below.

enter image description here

As it requires the URI to begin with HTTPS, I guess I have to enable it in my Express JS, as explained here.

Question

Before venturing in such (for me) complicated realm, does anybody have experience in this or know if this is the right way to test the Instagram API locally?

umbe1987
  • 2,894
  • 6
  • 35
  • 63
  • ok, maybe I found the solution: https://stackoverflow.com/a/33131470/1979665 and https://developers.facebook.com/docs/development/build-and-test/test-apps/. Will update the thread when I test it. – umbe1987 Jun 01 '21 at 09:34

2 Answers2

3

I was able to make it work with localhost, but it was very tedious.

These are the steps:

  • Enable https in the local environment (I used the library https-localhost).

  • [I don't know if this is mandatory] create a test app* from the main app (https://developers.facebook.com/docs/development/build-and-test/test-apps/)

  • Set the redirect OAuth URI to https://localhost:<MY_PORT>/auth/ and update also all other URIs in .../instagram-basic-display/basic-display/ settings.

  • Finally, don't forget to use the client-id (aka app-id) and app-secret of the test app in the requests, which are different than the parent app

*IMPORTANT: app-id and app-secret are different in test app!

umbe1987
  • 2,894
  • 6
  • 35
  • 63
  • NOTE: `https-localhost` library doesn't work with m1/m2 MacOS. You'll get a `bad cpu type in executable` error. Either use ngrok (as suggested by @saibbyweb) or follow this question to solve the problem https://stackoverflow.com/questions/64882584/how-to-run-the-homebrew-installer-under-rosetta-2-on-m1-macbook – Zaira Zafar Jul 10 '23 at 11:15
2

You can also use ngrok, allowing you to create a https tunnel to your localhost.

It enables you to access your localhost via https over the internet by creating a public url for you (e.g https://xxxxxxx.ngrok.io/) accepted as valid URI by developer dashboard.

Also, no need to create a test app for this. Great tool for dev. IMHO.

saibbyweb
  • 2,864
  • 2
  • 27
  • 48