50

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

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Martin Rasumoff
  • 1,463
  • 1
  • 11
  • 12
  • I also have this problem! the application is running in sandbox mode and i cant get any content. Weird.. – tubu13 Nov 23 '15 at 12:34
  • 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 Nov 23 '15 at 15:17
  • 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 Nov 23 '15 at 15:43
  • For getting scope: Go down to Login Permissions in the following link https://www.instagram.com/developer/authorization/ – suku Jan 21 '16 at 02:34
  • Documentation can be found here : https://www.instagram.com/developer/authentication/ – Rodrigo Lopez Guerra Mar 17 '16 at 18:49

3 Answers3

83

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.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Martin Rasumoff
  • 1,463
  • 1
  • 11
  • 12
  • This works! It's weird couldn't find anything mentioning that in the documentation. Instead it says the Client automatically has access to Sandbox users data. – Marcos Reboucas Nov 25 '15 at 18:29
  • 1
    Yeah Marcos...I could not find it in the documentation either...it took a lot of digging to find...glad it helped. – Martin Rasumoff Nov 27 '15 at 15:32
  • 1
    More information about SCOPE values: https://www.instagram.com/developer/authorization/ – Jason Lydon Apr 29 '16 at 15:23
  • 6
    This issue is not well documented. It has confused a lot of people so I wrote a short summary for developers on [how the new Instagram API works](https://medium.com/@emersonthis/instagram-on-websites-the-new-landscape-62c91d733894#.4z8g35g2s). – emersonthis Jul 08 '16 at 13:30
  • @Martin Rasumoff how can I find registered url : {"error_type": "OAuthException", "code": 400, "error_message": "Redirect URI does not match registered redirect URI"}` – Mehrnoosh Jun 09 '17 at 06:47
  • @Mehr, I don't understand your question. I posted the error message I was getting when trying to use Instagram API. Not sure what you are trying to do. – Martin Rasumoff Jun 10 '17 at 16:58
36

Here's a great example:

https://www.instagram.com/oauth/authorize?client_id=b23670e258o0fmk334jfu287c9f9953&redirect_uri=http://127.0.0.1:5000&response_type=code&scope=basic+public_content+follower_list+comments+relationships+likes

Simply add scope parameters at the end of the URL:

&scope=basic+public_content+follower_list+comments+relationships+likes
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Dr. Div
  • 951
  • 14
  • 26
  • Thanks for posting the actual scope parameters! Only thing better would be to also include the url to the documentation about scope. – rockfakie Sep 17 '16 at 06:22
0

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.

instagram

Jhonny
  • 1