Instagram Basic Display
The Instagram Basic Display API is an HTTP-based API that apps can use to get an Instagram user’s profile, images, videos, and albums. Since October 15, 2019, new client registration and permission review on Instagram API platform are discontinued in favor of the Instagram Basic Display API and you should use this method from now on.
To complete this tutorial, you will need:
- An app created at Back4App
- Set up a Subdomain for your Back4app app
First of all, it’s necessary to make sure that you have an existing app created at Back4App. However, if you are a new user, you can check this tutorial to learn how to create one.
The Authorization Window allows app users to grant your app permissions and short-lived Instagram User Access Tokens. After a user logs in and chooses which data to allow your app to access, we will redirect the user to your app and include an Authorization Code, which you can then exchange for a short-lived access token.
To begin the process, get the Authorization Window and present it to the user:
All parameters except state are required.
If authorization is successful, we will redirect the user to your redirect_uri and pass you an Authorization Code through the code query string parameter. Capture the code so your app can exchange if for a short-lived Instagram User Access Token.
Authorization Codes are valid for 1 hour and can only be used once.
A sample Authorization Code would be:
Note that #_ will be appended to the end of the redirect URI, but it is not part of the code itself, so strip it out.
Once you receive a code, exchange it for a short-lived access token by sending a POST request to the following endpoint:
A sample request would be like this:
and a successful response will look similar to this:
Now that the Sign In with Instagram is configured, you can start the development process passing the Access Token you retrieved for authentication. The format for AUTHDATA is:
Here is the method for the iOS SDK:
And here for the Android SDK: