0

"When using a desktop app and logging in, Facebook redirects people to the redirect_uri mentioned above and places an access token along with some other metadata (such as token expiry time) in the URI fragment:

https://www.facebook.com/connect/login_success.html# access_token=ACCESS_TOKEN... Your app needs to detect this redirect and then read the access token out of the URI using the mechanisms provided by the OS and development framework you are using. You can then skip straight to the Inspecting access tokens step."

This is what facebook documentation says about building a manual login flow through a desktop application. My question is how to read the access token from the redirected uri in a java desktop application?

hemal237
  • 23
  • 7
  • 1
    You mean that you run Java on the server or a Java-applet? If you run Java on the server you can't read it. The hash part of the URL is never sent to the server by web browsers – WizKid May 22 '14 at 18:43
  • If your app is spawning a webview, you may be able to access the current URI being displayed in that webview - how are you opening the login dialog? – Igy May 22 '14 at 19:46
  • I was just redirecting the following url https://www.facebook.com/dialog/oauth?client_id=*********redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token to a desktop browser. The browser shows the login dialog and once you authorize the app, it redirects to url with a access token appended as parameter, but this url stays just for seconds and then it changes to this:https://www.facebook.com/connect/blank.html#_=_ – hemal237 May 23 '14 at 06:46
  • Did you found an answer? – Razvan Cristian Lung Dec 14 '19 at 15:10

1 Answers1

-1

Have a look am my answer here: JAVA : how to extract youtube URL from facebook.com/l.php?u=

It deals with a similar thing, parsing a URL and looking for a parameter's content. You need to capture the URL which FB redirects to after the successful login. This URL contain the given Access Token.

Have a look at https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.0#login

Quote:

When using a desktop app and logging in, Facebook redirects people to the redirect_uri mentioned above and places an access token along with some other metadata (such as token expiry time) in the URI fragment:

https://www.facebook.com/connect/login_success.html#access_token=ACCESS_TOKEN...

Your app needs to detect this redirect and then read the access token out of the URI using the mechanisms provided by the OS and development framework you are using.

Community
  • 1
  • 1
Tobi
  • 31,405
  • 8
  • 58
  • 90