OAuthPermissionsException Instagram API in Sandbox

Martin Rasumoff picture Martin Rasumoff · Nov 23, 2015 · Viewed 47.4k times · Source

I would appreciate some input/direction on an issue I have been trying to solve for a while.

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

Any direction would be greatly appreciated.

Thanks,

Martin

UPDATE: 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:

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.

Hope this helps.

Martin

Answer

Martin Rasumoff picture Martin Rasumoff · Nov 23, 2015

UPDATE: 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.

Hope this helps.

Martin