4

I am creating a java application with RestFB. At this url, Facebook explains how to authenticate using facebook connect.

Basically, the steps are the following:

  1. Redirect to facebook as the example.

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream

2.If I invoke a HTTP request using the above URL, I get the following html response.

3.But if I invoke the above link via my browser, I get the following url which contains the OAuth code.

What I really want is the OAuth code which I am able to obtain only through the browser 3, I am unable to get that code via 2. I would like to programatically fetch the OAuth code in my standalone java program. How do I achieve that?

1 Answers1

1

You cannot obtain the OAuth code programmatically. This codes lets you perform actions on behalf of the user you are getting permission from.

When you redirect the browser to the URL at step 1, the browser renders a dialog where the user presses Allow or Skip. Only if the user allows and gives permission to your app, then you are given an OAuth code.

The response you get at 2 is perhaps the HTML of the screen you see on 3.

Furthermore; restFB has nothing to do with authentication. It becomes useful after you obtain the access key.

Last but not least, you might want to look into the Desktop Applications part of documentation.

Murat Derya Özen
  • 2,154
  • 8
  • 31
  • 44