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"
   }
}
  • How can I generate access token by my apps?
  • Or do I need to generate access token by own user account? if yes, how?
  • 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?

  • 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/


    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?


    The access token you are requesting looks like an 'application' access token. This token differs from a 'user' or 'page' access token and is used for different things.

    https://developers.facebook.com/docs/howtos/login/login-as-app/

    This can be used to modify the parameters of your App, create and manage test users, or read your application's insights for example. App access tokens can also be used to publish content to Facebook on behalf of a person who has granted a publishing permission to your application.

    Depending on what you are trying to actually do, an application token might be the wrong form of OAuth. Your example (searching for public posts with the term watermelon) doesn't require an OAuth token, so you're obviously trying a different type of graph search. Without saying what you're actually trying to access, it's impossible to actually advise you correctly.

    However, I'm going to guess that you're trying to get access to graph objects that require permissions from a specific user. If that's the case, then you need to get permissions from that user first, by requesting the scope of permissions that you require.

  • Process of gaining user OAuth Access Token (https://developers.facebook.com/docs/reference/dialogs/oauth/)
  • Possible Permissions (scope) that can be requested (https://developers.facebook.com/docs/reference/login/)
  • This will give you a short term access token for that user, which will allow you to anything within the scope of permissions for which you've requested permission.

    This token will only last for a short period after the user has logged into your app. It can also be promoted to a longer term access token

    https://developers.facebook.com/docs/howtos/login/extending-tokens/

    链接地址: http://www.djcxy.com/p/61602.html

    上一篇: Facebook API获取访问令牌

    下一篇: 用户访问令牌用于通过脸谱图进行搜索