Facebook app - getting AuthToken
I created a Facebook application using RestFB. In my local environment, it works fine. In order to host an application on the internet, I need to get a token. I am doing the following:
- Redirect from Facebook to my app url using app id and secret key.
- Retrieving code from url
- Trying redirection using code to get authtoken
I cannot complete step 3, please help me.
Most appreciated code example.
+3
source to share
2 answers
Did you follow 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
0
source to share
Get APP_ID / Key and APP_SECRET use below code
AccessToken accessToken = new DefaultFacebookClient().obtainAppAccessToken(APP_ID, APP_SECRET);
DefaultFacebookClient facebookClient = new DefaultFacebookClient(accessToken.getAccessToken());
It took a long time to find this simple method.
0
source to share