Question: I am just learning `restfb`. I registered an app on the FB site and got an app ID and Secret keys. However, as per [this tutorial](http://restfb.com), I am supposed to have an access token to initialize [DefaultFacebookClient](http://restfb.com/javadoc/com/restfb/DefaultFacebookClient.html). I tried to follow the instructions there but none sufficiently explained how to get the access token out of the app ID and secret key.

```
Request https://graph.facebook.com/oauth/authorize?client_id=MY_API_KEY&redirect_uri=http://www.facebook.com/connect/login_success.html

Facebook will redirect you to http://www.facebook.com/connect/login_success.html?code=MY_VERIFICATION_CODE

Request https://graph.facebook.com/oauth/access_token?client_id=MY_API_KEY& redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=MY_APP_SECRET&code=MY_VERIFICATION_CODE

Facebook will respond with access_token=MY_ACCESS_TOKEN

```

I did exactly that but every time I get

```
{
   "error": {
      "message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
      "type": "OAuthException",
      "code": 100
   }
}

```

Any idea what I am supposed to do to get an access token and start using the API?

Answer: 
It looks like the plugin authors assume that you will be authenticating a user with the [Login Dialog](https://developers.facebook.com/docs/concepts/login/permissions-login-dialog/) or the [JavaScript SDK](https://developers.facebook.com/docs/howtos/login/getting-started/). 

Both of these methods return a user access token you can use. You need your App\_ID and Secret to initialize these. Most Facebook operations require a user access token.

If you are making API calls solely to read public data, then you may be able to get away with an application access token. For this you can use the [DefaultFacebookClient().obtainAppAccessToken() method](http://restfb.com/#access-token-operations) of RestFB.
I am not sure if that's what you want, but anyway:

To get access token for users associated with an app, you can use the /accounts 'edge' (see [here](https://developers.facebook.com/docs/graph-api/reference/app/)).

Also, [this site about access tokens](https://developers.facebook.com/docs/facebook-login/access-tokens/) says that you can make calls to Graph API like that:
<https://graph.facebook.com/endpoint?access_token=app_id|app_secret>

Now, to combine that, to get the access tokens (in JSON format along with some other stuff):
<https://graph.facebook.com/>{your app id here}/accounts?access\_token={again, your app id here}|{your app secret here}

Please substitute the fields in the url above and remove all the { and } from it.