Integrate java application with Facebook using graph api.

14 / Nov / 2010 by Anshul Sharma 5 comments

These are few basic steps which will help you to integrate your java application with facebook using facebook graph api.

Steps :

1) Register your application at
2) Facebook will return Consumer Key and Consumer Secret for your application.

3) Create a login action:

String facebookPermissions = FacebookPermissions

// Login Action
String callbackUrl = "ApplicationUrl/controller/action"
String facebookAuthorizeUrl = ""  //             
redirect(url: facebookAuthorizeUrl)

4) Create a callback action .

///  Call back action: Where the facebook will redirect after succesful authentication.

String authCode = parms.code
String facebookTokenUrl = "${authCode}&redirect_uri=callbackUrl&scope=facebookPermissions"            
URL url = new URL(facebookTokenUrl)
String response = url.text
// Retrieve the access token from the response

6) Persist the access token for future use. The access token never expire until the user explicitly rejects the application from his settings.

Hope this helped!


Anshul Sharma


comments (5)

  1. ajay

    i am using same api for FB login but i m facing an problem me getting null in session after successful authentication

  2. Dino Gaffey

    Cool post. I have a site too. it’s about Twitter Followers, how you can build them and use this traffic source for monetization. Check it out, more traffic means more cash!

  3. jai

    Hi anshul ….could u plz give me the step by step procedure …how to login into my java application via facebook account…plzzzzz

  4. hans

    hi men, I need download the api for JAVA, know you authentic users with a aplication of desk? please guy, is for my proyect of the university.



Leave a Reply

Your email address will not be published. Required fields are marked *