Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible to get an access_token for Instagram Basic Display API

I'm trying to get an access_token from Instagram to use their Basic Display API for a new app (simply display tweets on a webpage).

I followed these steps: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

But I'm stuck at Step 5: Exchange the Code for a Token

The cURL request always returns a 400 error with the message: "Matching code was not found or was already used"

However, after many tests, I got an access_token one time only, but it expired about one hour later. This seems to be very random.

The Instagram Basic Display API seems rather new. A while ago, I have used apps created on the https://www.instagram.com/developer/ website and it used to work. Now this site display this message:

UPDATE: Starting October 15, 2019, new client registration and permission review on Instagram API platform are discontinued in favor of the Instagram Basic Display API.

... with a link to the developers.facebook.com.

like image 610
Maxime Freschard Avatar asked Oct 21 '19 15:10

Maxime Freschard


People also ask

How do I use Instagram basic API?

Go to the extensions' settings page [Ultimate Member > Settings > Extensions > Instagram Photos], enable the extension, select API type and paste API keys using the guidelines below. App ID - paste your Instagram App ID displayed in [App Dashboard > Products > Instagram > Basic Display].

Does Instagram API still work?

In 2018, Instagram shut down its public API. Meaning, third-party apps can no longer access the API from Instagram without permission. Third-party apps now need to be approved by Instagram before they can access the API.


1 Answers

I tried using the command-line tool as per the original docs(https://developers.facebook.com/docs/instagram-basic-display-api/getting-started), but no luck...

Here's what to do in 3 easy steps:

  1. First thing: Install Postman https://www.postman.com/downloads/
  2. Make a POST request to https://api.instagram.com/oauth/access_token with the parameters in the body, NOT the params. Make sure that the x-www-form-urlencoded option is enable.
  3. You should now get a status of 200 OK and a response with both access_token and user_id.
{
    "access_token": "IGQVJYUXlDN...",
    "user_id": 17841400...
}

Happy days!!

See the screenshot for the correct settings:

enter image description here

like image 152
Anas Avatar answered Sep 27 '22 17:09

Anas