50
votes

I am trying to access data related to a tag (let's call it "X") using Instagram API. I tried running it from Python and from the browser directly and got the same error:

{u'meta': {u'code': 400, u'error_type':u'OAuthPermissionsException',
u'error_message': u'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.'}}

This is the simple Python code I wrote in order to first make it work:

import requests

access_token = 'zzzzzzzzzzzzz'
parameters = {"q": "X",
              "scope": "public_content",
              "access_token": "zzzzzzzzzzzzz"}

response = requests.get("https://api.instagram.com/v1/tags/search",
                        params=parameters)
insta_posts = response.json()

Am I using the right URL for a Sandbox? I read the Instagram API documentation and applications in Sandbox do not need any type of approval for a scope change.

Also, the application is authorized for Sandbox only:

Screen Capture of Application Defined in Instagram API

2
I also have this problem! the application is running in sandbox mode and i cant get any content. Weird..tubu13
Hi tubu13...I will continue looking into how to solve this. Please let me know if you find out anything...any clue is welcome. I will do the same. Cheers.Martin Rasumoff
Hi tubu13, solved it...you need to change the scope of the authorization with Instagram before making the call to the API. I will explain this in the original post. Hope it helps.Martin Rasumoff
For getting scope: Go down to Login Permissions in the following link instagram.com/developer/authorizationsuku
Documentation can be found here : instagram.com/developer/authenticationRodrigo Lopez Guerra

2 Answers

83
votes

I figured out what was going on. One need to first change the scope of the authorization for the application. This is how I did it:

From your browser execute:

https://api.instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=REDIRECT-URI&response_type=code&scope=SCOPE

Just need to insert your data for the words in uppercase

Once that is done, the application is authorized for that scope.

As I had already the access token, I did not need to do steps 2 and 3.

36
votes