facebookfacebook-graph-apioauth-2.0facebook-wallfacebook-access-token

How to get a Facebook access token that has enough rights to get the posts in which you're tagged in?


The Facebook posts in which you're tagged in - using @Name - appear in your wall feed.


A friend of mine posted a link and tagged me in it:

The startup Guide


On the Graph API documentation, when I click on my wall feed link (Ctrl + F: Profile feed), I'm able to see this post:

  ...
  {
     "id": "XXX",
     "from": {
        "name": "XXX",
        "id": "XXX"
     },
     "to": {
        "data": [
           {
              "name": "XXX",
              "id": "XXX"
           },
           {
              "name": "Christophe Maillard",
              "id": "XXX"
           }
        ]
     },
     "message": "The startup Guide (cc XXX, Christophe Maillard)",
     "link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
     "name": "How to Get to Your First 1,000 Users",
     "caption": "mashable.com",
     "description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
     ...
  }
  ...

The URL of this feed is https://graph.facebook.com/me/feed?access_token=XXX.


When copy/pasting the given access token - the one replaced by XXX in the URL above - within the debugger, I get something like this:

Access Token Debugger

As we can see, the access token is generated by the app Test_console which used quite a lot of scopes.


Then, I go to the Graph API Explorer, I generate an access token using the Get Access Token button, and I specify all the scopes the debugger gave me, i.e. the ones the Test_console app used to generate its working access token. Finally, I access the URL me/feed by submitting the GET request. The problem: I can't see the post in question in which I'm tagged in with the explorer.

I also have my own app, and it reacts exactly like the Graph API Explorer: I can't find that post in my wall feed using the Graph API as well.

Obviously, it's possible to get the posts in which you're tagged in using the Graph API, because the Test_console app is able to generate an appropriate access token. But how can I get such an access token for my own app?


Solution

  • You need to grant the appropriate permissions for your app. In the graph api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me switch to your app in the applications field (top right) to see what permissions that currently grants your app (by clicking the "get access token" button again). Then make sure you add in the correct one (i think it's read_stream you're after ) https://developers.facebook.com/docs/authentication/permissions/