Question

I am new to the Instagram API and am finding some issues tying to understand how to get an access token.

What i have done is registered with instagram, created an application, and used the the client id and redirect url which when I post the following into a browser gives me a code=token

https://api.instagram.com/oauth/authorize/?client_id=65c3052cc4494f87bc7f941b61b1f3f5&redirect_uri=http://www.chillwebdesign.co.uk/feedcube/instagram&response_type=code

response

http://www.chillwebdesigns.co.uk/feedcube/instagram/?code=462318f96370433eac29a5f845aa0829

From this how do i get an access token?

<div class="pics"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">

$.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/users/[UserID]/media/recent/?access_token=[CODE]",
        success: function(data) {

        for (var i = 0; i < 10; i++) {
            $(".pics").append("<a target='_blank' href='" + data.data[i].link + "'><img src='" + data.data[i].images.low_resolution.url +"'></img></a>");
        }
        }

    });
});


</script>
Was it helpful?

Solution

The flow is well documented at http://instagram.com/developer/authentication/. You're done with step two, now it's on to step three, where you exchange the temporary code for a long lived access token.

The URL for this exchange is https://api.instagram.com/oauth/access_token and you'll need to POST client_id, client_secret, grant_type, redirect_uri, and code per the docs. cURL is the best way to do this.

OTHER TIPS

Here's a simple web interface I built for obtaining an Instagram API access token.

http://jelled.com/instagram/access-token

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top