-1

I sent this request in my Java application: https://www.facebook.com/dialog/oauth?client_id=CLIENT_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=email.

Next I showed the authorization page which was received as response. After submitting login info nothing happens

HiDeoo
  • 10,353
  • 8
  • 47
  • 47
Antonio
  • 304
  • 2
  • 11

1 Answers1

0

In redirect_uri you should set link on your site(for example: http://localhost/facebook-auth). So you will get request like this one:

http://localhost/facebook-auth/?code=AQD5q80zafjvVZoZex87ROxkCvWT9rZhjwZtkBLajYwH20KztPOI0jpb5lHZisPd3mA49Wu_onAeEioU5K6KVuoCliznf61B5bDfZSLFaIn6E7E49zqs4fO6NjTYyxN43LBttCvsSlirJOAtbOpB3oyMrl3bbjlPhGHsCyJzA-DypEIZ1c_36WAEBPmfSq3TroekvTLme3jIzZk0C-93cu8z#_=_

This code param you need to get the token.

Your next query will be like:

$params = array(
    'client_id'     => $client_id,
    'redirect_uri'  => $redirect_uri,
    'client_secret' => $client_secret,
    'code'          => $_GET['code']
);

$url = 'https://graph.facebook.com/oauth/access_token';

And in response you will get the token

dc914337
  • 415
  • 4
  • 14
  • I trying it in Java application. How I can do it in its case ? – Antonio Jul 17 '16 at 14:29
  • You just need to send requests like before. Your request was with an error(wrong redirect_uri. it should contain your site page). To get token you need to send second request containing received code. There is an [article](http://ruseller.com/lessons.php?id=1670) in russian about it. Also this question was on [stackoverflow](http://stackoverflow.com/questions/9566988/java-example-how-to-login-with-facebook-account-on-gae-using-oauth) and you can find java-code there. – dc914337 Jul 17 '16 at 14:36
  • I simply want get an access token in my Java client application. Why I need to specify site? – Antonio Jul 20 '16 at 19:42
  • In the Facebook developers page was said about it: "The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to facebook.com/connect/login_success.html. You con confirm that this URL is set for your app by going to the App Dashboard, clicking Facebook Login in the right-hand menu, and checking the Valid OAuth redirect URIs in the Client OAuth Settings section." – Antonio Jul 20 '16 at 20:20