JavaFX + Facebook


One of my previous post discussed about OAuth based authentication for Twitter, LinkedIn and Yahoo. Here I’ll discuss about authentication and usage of Facebook. It also provides OAuth based authentication, but the flow and usage is slightly different. Please refer to Desktop Application Authentication for more information.

For new application, please ensure that you register your application with Facebook. Specify Connect URL as base URL of deployed applet. Note down Application ID which will be used as client_id. Using client_id and Applet URL we can create the authorization URL as shown below.

Authentication Steps:

  • Click on above link and login to Facebook
  • Authorize JavaFX Sample application to access your Facebook profile
  • Page will be automatically redirected to the JavaFX Applet page
  • Extract the access_token parameter from URL
  • Pass access_token to JavaFX Applet as argument
  • Use Facebook Graph API to access all rest of information

Please refer to JavaFXFacebook.html for more information related to extraction and passing of access_token and client_id to JavaFX Applet. The view is implemented using ListView. Please refer to New to JavaFX 1.3: Cells for usage on ListView + ListCell APIs.

Update: There was some confusion due to additional steps related to “redirection of url to applet”. Yes, Twitter, LinkedIn and Yahoo didn’t have this concept. The difference is, there user needs to copy the access_token numbers from the page and paste it in application. In case of Facebook, due to url-redirection, the access_token can be automatically passed to application as argument. So user don’t have to do any copy-paste.

Try it out and let me know feedback

Advertisements

About Rakesh Menon
-

9 Responses to JavaFX + Facebook

  1. Pingback: Tweets that mention JavaFX + Facebook « Java, JavaFX and beyond… -- Topsy.com

  2. Mark Anro Silva says:

    Im also writing my own facebook app. This is very helpful.

  3. goddard says:

    Nice 🙂 It even doesn’t flicker when I make my browser window smaller and scroll the applet.

  4. Jumpa says:

    Hi Rakesh, me again, I’ve developed this app using Oauth on Twitter.
    http://insidethewall.altervista.org/twitjfx/
    It uses Twitter4J library and streaming API (opens up a stream,
    waiting for tweet from friends and containing “java”, “javafx” keywords).
    I’ve learned a lot from yout source code.
    Please feedback me here!

    • Rakesh Menon says:

      @Jumpa Application looks great.. I have one doubt, I authorized using OAuth access_token, but in next screen it again prompts for password. Can we use OAuth itself to perform all operation?

      • Jumpa says:

        Many thanks, sounds good from you!
        You’re perfectly right, but: Twitter Streaming API only supports Basic Auth
        method at the moment, so with OAuth I got Screen Name but no password to authenticate (they’re testing I suppose).
        Tomorrow I’ll post my second app: JFXBook (using your great hints).
        Thanks for the reply.

  5. Pingback: JavaFX links of the week, May 10 // JavaFX News, Demos and Insight // FX Experience

  6. Jumpa says:

    Just for information: http://insidethewall.altervista.org/blog/?p=29
    JFXBook, loading and displaying friends pic_square and pic_big from Facebook,
    pooling FB server every 30 seconds for updating pic_square opacity binded
    with online_presence; it’s using RestFB library and FQL.

    @Rakesh Something has changed: your example got some problems using
    http instead of https, besides during my deployment I had to add in index.html:

    access_token = decodeURIComponent(access_token.replace(/\+/g, ” “));

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: