Follow this Blog!

Jun 29, 2015

f Comment

[SOLVED] Fixing Facebook Graph API Error: "An access token is required to request this resource."

Amazon When I use Facebook's Graph API to see the comments posted on my website's FB comment plugin, I see a "400 Bad Request" error in my web browser with the following error:
{
  "error": {
    "message": "An access token is required to request this resource.",
    "type": "OAuthException",
    "code": 104
  }
}
How do you get an access token?

Background

I go to http://graph.facebook.com/comments?id=http://www.chtoen.com/&limit=10 to see 10 comments left in the Facebook comment plugin on my website http://www.chtoen.com/.

Then I go to http://graph.facebook.com/281398621990351_523770784419799/comments to see comments that are replied to the comment whose ID is 281398621990351_523770784419799. That's when I get the error "An access token is required to request this resource."

Read on to see how to solve it.

Solution

This error is caused by the URL not having the access token that Graph API needs to process your request. Simply go to https://developers.facebook.com/tools/access_token/ to see the App Token for your Facebook app. The App Token is a long string of numbers and letters.

So instead of going to

http://graph.facebook.com/281398621990351_523770784419799/comments

I need to go to

https://graph.facebook.com/281398621990351_523770784419799/comments?access_token=<my access token>

Now you should be able to see the results.

To find out how to crawl comments from an FB comments plugin, consult Using Facebook Graph API To Crawl Comments from a Facebook Comments Plugin.

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael