OAuthPermissionsException Instagram API in Sandbox
Instagram ApiInstagram Api Problem Overview
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:
Instagram Api Solutions
Solution 1 - Instagram Api
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:
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.
Solution 2 - Instagram Api
Here's a great example:
Simply add scope parameters at the end of the URL:
&scope=basic+public_content+follower_list+comments+relationships+likes