views:

248

answers:

1

Can someone please explain to me once and for good what are Session Key & Access Token? How do I catch those two? Why and when do I need them? When is it one-time and when is it not?

Also, what are the differences between them either the application already installed or not. Please do it in Java. I'm a new-to-facebook-api Java developer who's trying to get application works with Facebook.

This is my basic code so far:

FacebookJsonRestClient client = new FacebookJsonRestClient(API_KEY, SECRET);
HtmlDisplay HD = new HtmlDisplay("http://www.facebook.com/login.php?api_key=1668a3eee255c05918c4234bc4371beb&connect_display=popup&v=1.0&next=http://www.walla.co.il&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&session_key_only=true&req_perms=user_photos,publish_stream,offline_access");
hd.popUp();
client.auth_getSession(token, true);
System.out.println(client.getCacheSessionKey());

I also tried to put:

&auth_token=TOKEN

inside HD and get it with

CLIENT.auth_createToken();

but nothing works.. =(
Thank you!

A: 

Session key and access token are two mutually exclusive concepts. Session key was used in old REST API, access token is used in new OAuth and Graph API.

The java library you are using supports only old REST API and pretty outdated. I would suggest switching to Graph API java library, like RestFB.

Authorization process for OAuth is described in details here. You would also find a lot of examples on RestFB page.

serg

related questions