Platform
Instagram Basic Display
9 min
instagram basic display api tutorial introduction 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 prerequisites to complete this tutorial, you will need an app created at back4app see the create new app tutorial to learn how to create an app at back4app set up a subdomain for your back4app app see activating your web hosting and live query to learn how to create a subdomain in back4app an instagram developer account 1 create a new 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 https //www back4app com/docs/get started/new parse app to learn how to create one 2 present the authorization window 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 1 https //api instagram com/oauth/authorize 2 ?client id={instagram app id} 3 \&redirect uri={redirect uri} 4 \&scope={scope} 5 \&response type=code 6 \&state={state} //optional all parameters except state 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 https //myapp back4app io/auth/?code=aqbx hbsh3 # 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 3 retrieve your token once you receive a code, exchange it for a short lived access token by sending a post request to the following endpoint 1 post https //api instagram com/oauth/access token a sample request would be like this 1 curl x post \\ 2 https //api instagram com/oauth/access token \\ 3 f client id=990602627938098 \\ 4 f client secret=eb8c7 \\ 5 f grant type=authorization code \\ 6 f redirect uri=https //socialsizzle herokuapp com/auth/ \\ 7 f code=aqbx hbsh3 and a successful response will look similar to this 1 { 2 "access token" "igqvj ", 3 "user id" 17841405793187218 4 } 4 start the development 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 1 { 2 "instagram" { 3 "id" "user's instagram id (string)", 4 "access token" "an authorized instagram access token for the user" 5 } 6 } here is the method for the ios sdk 1 pfuser loginwithauthtype(inbackground "instagram", authdata \["access token"\ tokenstring, "id" user]) continuewith { task > any? in 2 3 } and here for the android sdk 1 map\<string, string> authdata = new hashmap\<string, string>(); 2 authdata put("access token", tokenstring); 3 authdata put("id", user); 4 parseuser loginwithinbackground("instagram", authdata){ 5 6 }