Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User access token for search via facebook graph

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?
like image 321
Googlebot Avatar asked Oct 17 '11 10:10

Googlebot


People also ask

Does Facebook use token based authentication?

When your app uses Facebook Login to authenticate someone, it receives a User access token. If your app uses one of the Facebook SDKs, this token lasts for about 60 days. However, the SDKs automatically refresh the token whenever the person uses your app, so the tokens expire 60 days after last use.

What can I do with Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.


2 Answers

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/

like image 89
Surabhil Sergy Avatar answered Oct 25 '22 01:10

Surabhil Sergy


For searching the facebook graph API using

http://graph.facebook.com/search?q=watermelon&type=post

you need a valid user access token. A user access token is different from App Access token. A user access token is created when a user authenticates your app with different access permissions which is generally close to 212 letters long.

A changes was made in the graph API in July,2013 whereby you will need to have a valid user access token to search for users and posts. The user access token could be generated by you yourself authenticating your app and generating an user access token for your app.

But the question remains, How should we generate a user app token for our apps without making other users to authenticate our apps?

like image 30
naive Avatar answered Oct 25 '22 00:10

naive