Facebook graph API: simple search for users by name

Peter picture Peter · Aug 13, 2015 · Viewed 27.5k times · Source

I would like to do a simple search for users by their name from a desktop application using Facebook's graph API. The result I want to have is a list of user names and the link to their profile. I spent several hours reading the documentation but it is still not very clear to me, which access tokens I would need. I have created a developer account on Facebook and added a new app. I've got an app access token and I've tried to do a search using the following URL:

https://graph.facebook.com/search?q=john&access_token={my_app_access_token}

I got the following response:

{
   "error": {
      "message": "An unknown error has occurred.",
      "type": "OAuthException",
      "code": 1
   }
}

My question now is, if it is possible to do such a simple search without user access token. So the user sitting in front of my desktop application should NOT have to enter his facebook credentials somewhere - never. Can this be done somehow?

Answer

Björn Kaiser picture Björn Kaiser · Aug 20, 2015

When searching, you should provide the search type (in your case user) and to answer your question, no, a user access token is required to search, app tokens won't work for user searches (documented here)