3

I have created a Facebook app using RestFB. In my local environment it is working fine. To put the app on the web, I need to get token. I am following these steps:

  1. Redirecting from Facebook to my app url using app id and secret key.
  2. Getting code from url
  3. Trying to redirect using code to get authtoken

I am not able to complete step 3, Please help me.

A sample code will be most appreciated.

2 Answers2

0

Have you followed this step exactly ?

Create a Facebook Application
Request https://graph.facebook.com/oauth/authorize?client_id=MY_API_KEY& redirect_uri=http://www.facebook.com/connect/login_success.html& scope=publish_stream,create_event
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
Vinit Prajapati
  • 1,593
  • 1
  • 17
  • 29
0

Get your APP_ID/Key and APP_SECRET use the below code

AccessToken accessToken = new DefaultFacebookClient().obtainAppAccessToken(APP_ID, APP_SECRET);
DefaultFacebookClient facebookClient = new DefaultFacebookClient(accessToken.getAccessToken());

Struggled long time to find this simple method.

fawzib
  • 774
  • 2
  • 9
  • 23