Getting invalid oauth access token: where is the token I need?

rivimey picture rivimey · May 7, 2014 · Viewed 22.6k times · Source

I would like help obtaining/locating the correct access_token value for an API call.

I'm configuring an application that wants to search Facebook using the graph-api search request at https://graph.facebook.com/fql, for which I need an access_token. The application is a backend server so there's no UI and no users.

I registered a new 'app' using the developer pages 'Create a New App' link, so I now have an app at: https://developers.facebook.com/apps/<> and from that I get an 'app secret' token. Digging into the Advanced settings page for the app there is also a Client token.

However using either token results in the following JSON error:

{"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190}}

Can anyone point me to where I've gone wrong?

==

The following 'curl' request demonstrates the command working correctly, but it's only usable token-less like this occasionally, so the app needs &access_token=...stuff... adding to the parameters.

$ curl 'https://graph.facebook.com/fql?q=select%20url,%20share_count,%20like_count,%20comment_count,%20click_count,%20total_count%20from%20link_stat%20where%20url%20=%20"http%253A%252F%252Felifesciences.org%252Fcontent%252F2%252Fe01233"'

{"data":[{"url":"http\u00253A\u00252F\u00252Felifesciences.org\u00252Fcontent\u00252F2\u00252Fe01233","share_count":0,"like_count":0,"comment_count":0,"click_count":0,"total_count":0}]}

Answer

Owen Cao picture Owen Cao · May 8, 2014

The 'app secret' and 'Client token' will not work.
What you need is an Access Token, refer to this.