User access token for search via facebook graph

Googlebot picture Googlebot · Oct 17, 2011 · Viewed 10k times · Source

According to the instruction given here searching public information (as https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE) needs to have a valid access token. As I know access token is when a user authorized an apps to access his information; but this is searing the public information. How to get an apps access token to search public information?

In that page, facebook automatically add my access token to the link as

https://graph.facebook.com/search?q=watermelon&type=post&access_token=MY_ACCESS_TOKEN

I created an access token by my apps as https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=SECRET_ID&grant_type=client_credentials

When I use the generated access token in url https://graph.facebook.com/search?q=watermelon&type=post&access_token=GENERATED_ACCESS_TOKEN, it gives an error

{
   "error": {
      "message": "A user access token is required to request this resource.",
      "type": "OAuthException"
   }
}
  1. How can I generate access token by my apps?
  2. Or do I need to generate access token by own user account? if yes, how?
  3. Since it is searching public profile, facebook should not need authorization on every search, can I generate a permanent access token to perform different searches?

Answer

Surabhil Sergy picture Surabhil Sergy · Jun 27, 2013

The Graph API Search interface has changes pending with the Q3 2013 migration. The following change will go into effect on July 10, 2013:

Graph API search changes App access tokens will be required for all search Graph API calls except Places and Pages. Search for application will no longer be supported.

https://developers.facebook.com/blog/post/2013/04/03/platform-updates--operation-developer-love/