I am trying to programmatically get a facebook graph api token so far i have used scibe to get the authorazation url and the code is :
OAuthService service = new ServiceBuilder()
.provider(FacebookApi.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback("callbackurl")
.build();
Scanner in = new Scanner(System.in);
System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ===");
System.out.println();
// Obtain the Authorization URL
System.out.println("Fetching the Authorization URL...");
String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
System.out.println("Got the Authorization URL!");
System.out.println("Now go and authorize Scribe here:");
System.out.println(authorizationUrl);
the problem is that after that i cannot get the redirect url that contains the code .For tha perpose i use htmlunit a headless browser and the code is :
HtmlUnitDriver Browser_Session= new HtmlUnitDriver();
Browser_Session.setJavascriptEnabled(true);
Browser_Session.navigate().to(authorizationUrl);
System.out.println(Browser_Session.getCurrentUrl()); //This fetches the current re-directed URL.
and the response is THIS URL
instead of
http://www.Redirecturl.com/?code=XXXXXXXXXXXXXXXX
if i do this manualy eg. copy paste the authorazation url then the broser redirect to the correct page!!
if i do this manualy eg. copy paste the authorazation url then the broser redirect to the correct page!!
That's the point.
Automated Facebook auth defeats the purpose of Facebook Auth.
It is designed to be manual, user initiated.