Platform
Sign Up With Instagram
9 min
instagram oauth tutorial introduction instagram oauth enables users to sign in to apps using their instagram account through oauth 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 create a new instagram app client log into your instagram developer account https //www instagram com/developer/ and sign up as a developer enter your website, telephone, and a description for your app accept the terms to proceed go to overview click on register your application register your application click on register a new client register a new client fill up the application name application name , description description , company name company name , website url website url , redirect uris redirect uris , privacy policy url privacy policy url , and contact email contact email for the valid redirect uris valid redirect uris , if you are only trying to retrieve your access token, you can leave it as otherwise, you should use the production uri for redirection at this point, you should have a client like the image below click on manage manage and under the security security tab, uncheck the disable implicit oauth disable implicit oauth 3 retrieve your token if you left your redirect uris redirect uris as localhost localhost , there are two ways you can retrieve your token the first one is using your browser of choice, and going to the following url https //api instagram com/oauth/authorize/?client id=client id\&redirect uri=redirect uri\&response type=code https //api instagram com/oauth/authorize/?client id=client id\&redirect uri=redirect uri\&response type=code just change the client id client id and redirect uri redirect uri using the values you got from your newly created client this will redirect you to an invalid page, but show you the access token in the url the other way to retrieve such a token is to run the following curl command, replacing the client id client id , client secret client secret , and redirect uri redirect uri for your values 1 curl \\ f 'client id=client id' \\ 2 f 'client secret=client secret' \\ 3 f 'grant type=authorization code' \\ 4 f 'redirect uri=redirect uri' \\ 5 f 'code=code' \\ 6 https //api instagram com/oauth/access token that command will also output your access token 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 }