Guides on system administration, 3D printing and other technology related projects.

Quickly Generate an Instagram Access Token

Quickly Generate an Instagram Access Token

Whether you’re looking to create a live Instagram feed for your site, or display specific images from an Instagram feed, or even creating a custom web application that needs to access Instagram data, you’ll first need to generate an access token for Instagram’s API.

The process isn’t really too self intuitive. So, I’ll show you the steps that you’ll need to follow in this guide.

Step 1: Register your application

Go to https://www.instagram.com/developer/ and register a new application.

instagram-register-your-application

instagram-developer-signup

Step 2: Register a new client

To register a new client, click the Manage Clients link on the top and then the Register a New Client button below it.

instagram-register-new-client-link

Fill out the fields for Application Name, Website URL and Valid redirect URI.

Make sure to specify your website’s proper addresses.

instagram-register-new-client

You’ll now see the new client that you’ve created.

instagram-client

Step 3: Disable implicit OAuth

If you don’t disable implicit OAuth, your visitors won’t be able to see to see your feed. And you’ll receive the following error message:

"meta": {
    "code": 400,
    "error_type": "OAuthPermissionsException",
    "error_message": "This client has not been approved to access this resource."
}

Go to the Instagram Manage Clients page and then click the Manage link for your project.

instagram-manage-clients

Next click the Security tab.

instagram-manage-clients-security

Now uncheck the Disable implicit OAuth option.

instagram-disable-implicit-oauth

Step 4: Access the API URL

Now in your browser, go to the API URL:

https://www.instagram.com/oauth/authorize/?client_id=75cfae1c5d35478ca595c271ba113ec1&redirect_uri=https://ericmathison.com/blog&response_type=token&scope=public_content

Make sure to replace the client_id with your client ID and redirect_uri variable with your website address.

You’ll also want to make sure that you include the scope=public_content otherwise you’ll receive the following error:

"meta": {
    "code": 400,
    "error_type": "OAuthPermissionsException",
    "error_message": "This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions."
}

Step 5: Authorize your website

After visiting the URL in the previous step, you’ll be presented with a screen which asks you to authorize your website for API access. Click the Authorize button.

instagram-authorize-sandbox-user

Step 6: Copy your access token

Congratulations!

If you followed all of the steps correctly, you’ll now be redirected to your website with a newly generated access key for you in the URL.

instagram-access-token

Instagram is known to change how their API works. So if this method isn’t working properly, let me know in the comments below!


© Eric Mathison 2017-2020.